I have following vbscript:
set objShell = Createobject("wscript.shell")
objShell.Run """Scripts\Rec.bat""", 0
objShell.Run """Scripts\Prod.bat""", 0
Set objShell = Nothing
The above vbscript is stored in USB drive and i am trying to launch it from usb. Now problem is when i normally run this vbscript it executes. But when i do run as administrator from context menu following error occurs "System cannot find the file specified"
I tried to debug the problem using another below script:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")
strPath = objShell.CurrentDirectory
strDrive = objFSO.GetDriveName(strPath)
Wscript.Echo strDrive
When i run it normally it echo F: that is my usb drive letter. But when i run as admin it echo C:
So the batch file location is being searced to C:\Scripts\Rec.bat instead of F:\Scripts\Rec.bat thats why this error is comming.
Can anyone help??
I want to run vbscript as admin and still retain the usb drive letter path because the code in my Rec.bat requires admin privilege