buddivictory Posted January 23, 2004 Share Posted January 23, 2004 I tried running the following command and I get can't find program, though I can run the command from the command prompt dos window with no problem. Please advise. Command attempting to run: RunWait('pushd \\engwin2\util') Without the run wait this will automatically map a drive letter with the latest availabe letter. Thanks to all. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 23, 2004 Developers Share Posted January 23, 2004 (edited) what about? RunWait(@comspec & '/c pushd \\engwin2\util') Edited January 23, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
buddivictory Posted January 23, 2004 Author Share Posted January 23, 2004 nope...did not work Link to comment Share on other sites More sharing options...
scriptkitty Posted January 23, 2004 Share Posted January 23, 2004 also make sure to use a space before the /c as in Good: RunWait(@comspec & ' /c pushd \\engwin2\util') Bad: RunWait(@comspec & '/c pushd \\engwin2\util') AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 23, 2004 Developers Share Posted January 23, 2004 also make sure to use a space before the /c as in Good: RunWait(@comspec & ' /c pushd \\engwin2\util') Bad: RunWait(@comspec & '/c pushd \\engwin2\util')yeap, you are right! there's a space missing before the /c in my post ! SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
buddivictory Posted January 23, 2004 Author Share Posted January 23, 2004 Thanks for the help..but that's not working either. Link to comment Share on other sites More sharing options...
buddivictory Posted January 23, 2004 Author Share Posted January 23, 2004 Is there a way to map the next available drive letter in AutoIT? Link to comment Share on other sites More sharing options...
GrahamS Posted January 23, 2004 Share Posted January 23, 2004 Two suggestions First, try running a command window and then sending your commands as key strokes to the command window: run(@ComSpec) WinWaitActive(@ComSpec) send("pushd \\engwin2\util{ENTER}") sleep(250) (the sleep is there to allow the command to complete before issuing your next command. You will have to adjust the time as appropriate) Second, the help for PUSHD states the Command Extensions must be enabled to allow network paths to be accepted. Although cmd.exe (at least on Win 2K) is supposed to enable Command Extensions by default, you could try explicitly enabling them using RunWait(@comspec & ' /E:ON /c pushd \\engwin2\util') GrahamS Link to comment Share on other sites More sharing options...
buddivictory Posted January 23, 2004 Author Share Posted January 23, 2004 Thanks. That works but how do I get the letter that it generates into AutoIT for applications installation. Thks in advance. Link to comment Share on other sites More sharing options...
GrahamS Posted January 23, 2004 Share Posted January 23, 2004 Function DriveGetType will set @Error to 1 if the drive doesn't exist (and returns the drive type if it does). PUSHD help states that it creates a temporary drive for the network path and that the temporary drive letters are allocated from Z: on down, using the first unused drive letter found. You could use DriveGetType in a for loop to find the "highest" unused drive letter first, run your pushd command, and then check that the previously found drive letter is now mapped to a network drive Sorry, but I cannot test this at the moment - no network GrahamS Link to comment Share on other sites More sharing options...
scriptkitty Posted January 24, 2004 Share Posted January 24, 2004 To get the drive, just send something to a temp file, as in. Run(@ComSpec) WinWaitActive(@ComSpec) send("pushd \\engwin2\util{ENTER}") sleep(250) $file="temp.txt" $file2=@TempDir&"\"&$file send("dir >"&@TempDir&"\"&$file&"{enter}") While FileExists ($file2)=0 sleep(100) Wend winclose(@ComSpec) $file = FileOpen($file2, 0) $line = FileReadLine($file2) $drive=StringMid ($line,StringInStr ($line,"drive ")+6,1) MsgBox(0, $line,$drive) FileClose($file2) FileDelete($file2) Sloppy, but effective. Sorry only tested on WinXP atm. AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
ryanm Posted February 7, 2004 Share Posted February 7, 2004 The drive you just mapped with pushd is unmapped when the command processor closes. Try it in a cmd window, then exit and watch the drive disappear. Link to comment Share on other sites More sharing options...
scriptkitty Posted February 7, 2004 Share Posted February 7, 2004 Hmm, on my system, I keep the drive letter even after exiting the window, Win2k Pro. My Popd created Z drive stays there until I disconect it. I will test it on other OS soon. AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
Administrators Jon Posted February 7, 2004 Administrators Share Posted February 7, 2004 You can also use "net use * \\engwin2\util" which maps a free drive. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
scriptkitty Posted February 7, 2004 Share Posted February 7, 2004 Yea, net use makes it a bit simpler, and can do it in backround. for $i=90 to 65 step -1; Capital Z-A in Chr() $Status = DriveStatus( Chr($i)&":\" ) if $Status="Invalid" then; checks if already assigned $driveX=Chr($i) $err=runwait(@comspec & " /c net use "& $driveX &": \\engwin2\util","",@SW_HIDE) exitloop endif next if $err=0 then msgbox(1,$err& " info","\\engwin2\util mapped to " & $driveX) else msgbox(1,$err& "Error","Cannot map drive to \\engwin2\util") endif AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
ryanm Posted February 10, 2004 Share Posted February 10, 2004 Hmm, on my system, I keep the drive letter even after exiting the window, Win2k Pro.My Popd created Z drive stays there until I disconect it.I will test it on other OS soon.You're right, ScriptKitty. I just verified that in Win2K it disconnects all pushd'd drives when the cmd window closes. In WinXP it leaves it. Might want to code for both OSes if you have a mix. Use a 'net use' command. Or better yet they could build in a drive mapping command. Link to comment Share on other sites More sharing options...
Guest Platrix Posted February 11, 2004 Share Posted February 11, 2004 I had an similar problem and have writen a special script for them: it checks for first aviable drive letter after "c" $drive = drivegetdrive("all") $map = 0 for $i = 2 to $drive[0] - 1 if asc($drive[$i + 1]) - asc($drive[$i]) > 1 then $map = chr(asc($drive[$i]) + 1) & ":" exitloop endif next if $map = 0 then $map = chr(asc($drive[$i]) + 1) & ":" runwait(@comspec & " /c " & "net use " & $map & " \\server\share\", "", @sw_hide) ... runwait(@comspec & " /c " & "net use " & $map & " /d", "", @sw_hide) Link to comment Share on other sites More sharing options...
Bartokv Posted February 11, 2004 Share Posted February 11, 2004 FYI: The "/PERSISTENT:YES" command-line argument may be used to specify the drive mapping is to become permanent. (Until manually disconnected)Likewise "/PERSISTENT:NO" may also be used to specify the drive mapping is to only be designated for the current boot. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now