AoN
Internet Programmer
- Aug 1, 2012
- 114
Heads up, below this is all a copy & paste from another forum I haven't gotten any responses from. ^^'
Basically, I have a batch that will pull the current network drive mappings from the registry for a given SID and save it to a specified username's desktop.
This requires access to the machine (as if locally, so NetMeeting, RDC, etc.) and specifying the username and SID. What I'm trying to do is make it a remote batch, something that I can supply just the machine name and it automatically pull the current username/SID and fill in the blanks.
So, here's the code I have without remote access or automation:
This works just fine from the local machine. Now I've tried modifying it to pull the current users information, but have only found two ways of doing so, %USERNAME% and "wmic computersystem get Username". The second one is great because it can be used remotely, which is what I'm ultimately hoping for.
Here's the issue with automating the username, the first the variable option returns the username of my administrator account and the command returns my administrator account + domain name (locally). Remotely, the username would only grab my account on my local machine while the command pulled the right information, but I can't use the domain name.
So, that's the first problem. Second it converting the username to the SID information. I don't have a clue how I'd do that. Lastly, how can I make it run remotely, since the HKU tree is not accessible remotely in Windows?
Any ideas would be greatly appreciated, even if it does come down to having to be a locally ran script, being able to remove the chance of getting the username/SID wrong would be very helpful. ^^
Basically, I have a batch that will pull the current network drive mappings from the registry for a given SID and save it to a specified username's desktop.
This requires access to the machine (as if locally, so NetMeeting, RDC, etc.) and specifying the username and SID. What I'm trying to do is make it a remote batch, something that I can supply just the machine name and it automatically pull the current username/SID and fill in the blanks.
So, here's the code I have without remote access or automation:
Code:
@Echo off
set user=
set sid=
cls
set /P user=Enter the username of the desktop the save to:
set /P sid=Enter the SID of the user:
reg export HKU\%sid%\Network "D:\Documents and Settings\%user%\Desktop\Network Drives.reg"
pause
exit
Here's the issue with automating the username, the first the variable option returns the username of my administrator account and the command returns my administrator account + domain name (locally). Remotely, the username would only grab my account on my local machine while the command pulled the right information, but I can't use the domain name.
So, that's the first problem. Second it converting the username to the SID information. I don't have a clue how I'd do that. Lastly, how can I make it run remotely, since the HKU tree is not accessible remotely in Windows?
Any ideas would be greatly appreciated, even if it does come down to having to be a locally ran script, being able to remove the chance of getting the username/SID wrong would be very helpful. ^^