Posts

How to use %username% variable in vbscripts

If you try to use a vbscript to map a network drive using the %username% variable it will not work. The reason for this is the %username% variable only works in .bat files. The equivelant in vbscript is objNetwork.UserName That being said here is an example
on error resume next
Set WshNetwork = WScript.CreateObject(“WScript.Network”)
WshNetwork.RemoveNetworkDrive “U:”
WshNetwork.MapNetworkDrive “U:”, “mawfi-2008r2.mawfi.localusers$” & WshNetwork.UserName , True

Get a remote command prompt

It is pretty easy to get a remote command prompt if you need to remotely gain access to another PC’s command prompt. Here are the steps.
1. Download PsTools, http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
2. Open a command prompt. Start>run cmd
3. Next from the command prompt browse to the location that you extracted your files to.
4. Run PsExec computername cmd.exe
5. You are now at the cmd prompt of your remote machine.