1bigdork
asked on
Executing vbscript commands with alternate credentials
Is there a way to authenticate to windows within a vbscript and then run commands using those credentials? For example if I had the following simple code could I authenticate to windows with a local account and it execute the code with those credentials?
Set objShell = CreateObject("Wscript.Shel l")
objShell.Run strCmd,0,True
Set objShell = CreateObject("Wscript.Shel
objShell.Run strCmd,0,True
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm trying to run an external program (or msi in actualilty) via the vbscript.
I've always just used cpau in the past for something like this but this time i'm having some trouble getting all the quotes right in passing the path to the file to cpau. This mostly stems from the file name having a space in the name and for some reason if I change the name the msi won't completely uninstall everything properly so that the updated version can be installed.
Just running the file without using cpau requires me to put three quotes on each side of the path before it can find the file.
oshell.run """.\aFolderName\file name.msi"""
So how do I do this when I pass the file path to cpau?
oshell.run "%SystemRoot%\System32\cpa u -u username -p password -ex "".\aFolderName\file name.msi"" -wait -profile", , True
I've always just used cpau in the past for something like this but this time i'm having some trouble getting all the quotes right in passing the path to the file to cpau. This mostly stems from the file name having a space in the name and for some reason if I change the name the msi won't completely uninstall everything properly so that the updated version can be installed.
Just running the file without using cpau requires me to put three quotes on each side of the path before it can find the file.
oshell.run """.\aFolderName\file name.msi"""
So how do I do this when I pass the file path to cpau?
oshell.run "%SystemRoot%\System32\cpa
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Using the chr(34) doesn't seem to fix the problem. I think there may just be an issue with the way in which cpau handles strings. I guess I'll have to find a different way. Thanks for the help.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
"WbemScripting.SWbemLocato r" cannot be used for connecting WMI on local system; How can we connect to WMI on local system using alternate credentials?
are you trying to run an external program via VB,. or acruire information via VB?
here is one to get information from another system using credentials in the script..
if i ned to run a script locally on a box and needs to use alternative credentials. i use CPAU to encapsulate the script and run it with another id.
http://www.joeware.net/freetools/tools/cpau/index.htm
Open in new window