Jump to content
Sign in to follow this  
royatsumit

RunAsWait 'Net Use' in @ ComSpec?

Recommended Posts

royatsumit

I cannot work out how to use RunAsWait, or even just Run to execute the following command:

"net use s: \\servername\share".

I have tried:

Runaswait($sUserName, @LogonDomain, $sPassword, 0, @COMSPEC & "/c" & "net use x: \\server\share" )

where $sUsername and $sPassword are correct for Domain Admin.,

Runwait(@COMSPEC & "/c" & "net use x: \\server\share")

and many other formats and all appear to return error 1.

How can I set up a mapped drive for a RunAs user within an AutoIt script. This is critical for the running of a Hospice medical application and is becoming urgent.

Share this post


Link to post
Share on other sites
muncherw

Run(@ComSpec & " /c " & 'net use s: \\servername\share\' , "", @SW_HIDE)


Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]

Share this post


Link to post
Share on other sites
royatsumit

Run(@ComSpec & " /c " & 'net use s: \\servername\share\' , "", @SW_HIDE)
Thank you for the prompt response but unfortunately this doesn't resolve my problem.

I need to map the drive as another user (with domain admin rights) and then execute a program with the same admin rights. This is waht I currently have in a test scritpt and it doesn't work:

RunAsWait($sUserName, @LogonDomain, $sPassword, 0, @ComSpec & " /c " & 'net use y: \\gcsrv02\AEGIS\ /persistent:yes' , "", @SW_HIDE)RunAsWait($sUserName, @LogonDomain, $sPassword, 0, "notepad.exe y:test.csv", "",@SW_MAXIMIZE )

The notepad execution cannot find the test.csv because the drive is not mapped at that time.

Any further help would be appreciated.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.