Incroyable HULK Posted March 27, 2005 Share Posted March 27, 2005 I want to automate the way a group of user is connecting to a Remote Computer using our VPN and RDC (Windows Remote Desktop Connection). First, I've managed to get a batch file like this one:start Extranet.exe -auth 0 -user LOGIN -pwd PASSWORD -serverip 000.000.000.000 -sstart %SystemRoot%\system32\mstsc.exe REMOTECOMPUTER.rdpThe only problem is that there is a halt box where I have to click OK after the VPN connection is established... (the VPN client is Nortel Contivity)And then, there is a warning message with RDC telling that I will be sharing my Hard Drive and once again I have to click OKAny way to send the ENTER key with a batch file? Or maybe it is possible to use AutoIT but I'm not too familiar with this program... Link to comment Share on other sites More sharing options...
durex Posted March 27, 2005 Share Posted March 27, 2005 Batch wont do what youre looking for, youll need to use AutoIt or VBScript. Ive never used AutoIt, but for VBScript...Open notepad and copy the following text into it...Set WshShell = WScript.CreateObject("WScript.Shell")' Set %Systemdrive% variable to 'SYSD'SYSD = WshShell.ExpandEnvironmentStrings("%Systemdrive%")' Launch Nortel AppWshShell.Run ("Extranet.exe -auth 0 -user LOGIN -pwd PASSWORD -serverip 000.000.000.000 -s")' Wait until Nortel App comes upDo until WshShell.AppActivate ("PLACE TEXT OF TITLEBAR OF YOUR NORTEL PROMPT HERE") WScript.Sleep 2000Loop' Hit EnterWshShell.SendKeys "{ENTER}"WScript.Sleep 1000'Launch RDCWshShell.Run (SYSD & "\system32\mstsc.exe REMOTECOMPUTER.rdp")' Wait until RDC box comes upDo until WshShell.AppActivate ("PLACE TEXT OF TITLEBAR OF THE RDC PROMPT HERE") WScript.Sleep 2000Loop' Hit EnterWshShell.SendKeys "{ENTER}"Edit the "WshShell.AppActivate" lines and place in the text of the Titlebars of the app prompt windows as mentioned.Save it as <whatever>.vbs and place this in the same location as 'Extranet.exe' and 'REMOTECOMPUTER.rdp'This should work, but without testing with the actual apps cant guarantee itll work of course... Link to comment Share on other sites More sharing options...
Incroyable HULK Posted March 27, 2005 Author Share Posted March 27, 2005 Thank you so much DUREX! Your VBS Skills kills! (but you forgot to put \WINDOWS\... in front of System32\mstsc.exe) BTW, is there a way to compile this script to a standalone .EXE ? Link to comment Share on other sites More sharing options...
durex Posted March 27, 2005 Share Posted March 27, 2005 Thank you so much DUREX! Your VBS Skills kills! (but you forgot to put \WINDOWS\... in front of System32\mstsc.exe) BTW, is there a way to compile this script to a standalone .EXE ?<{POST_SNAPBACK}>Np.. as far as the 'forgot to put windows in fron of sys32' I did put it in front of it.. thats what the 'SYSD &' is for... if you look at the top of the script SYSD is set to %systemdrive% and the '&' symbol concatenates (aka puts together) that variable with the rest of the line in quotes.And to be honest, if you want to get into symantics, you dont need the 'C:\windows\system32' in front of mstsc.exe anyway because the sys32 directory is in your system path, which means you can actually launch any executables that reside in that directory from anywhere.G'head and try it.. just goto Start>Run and type 'mstsc', itll launch without issue (should)And lastly in regards to compiling this to exe, if you have Microsofts Visual Studio you can compile it.. im not aware of any other 3rd party apps that do this (although there may be one that exists) Link to comment Share on other sites More sharing options...
Incroyable HULK Posted March 27, 2005 Author Share Posted March 27, 2005 And to be honest, if you want to get into symantics, you dont need the 'C:\windows\system32' in front of mstsc.exe anyway because the sys32 directory is in your system path, which means you can actually launch any executables that reside in that directory from anywhere.Yep! you're right!!! Almost forgot about that...Is there a way to use a variable to get to the Nortel Network Folder?I've tried this without success:' Set %ProgramFiles% variable to 'PROG'PROG = WshShell.ExpandEnvironmentStrings("%ProgramFiles%")' Launch Nortel AppWshShell.Run (PROG & "Nortel Networks\Extranet.exe -auth 0 -user LOGIN -pwd PASSWORD -serverip 000.000.000.000 -s") Link to comment Share on other sites More sharing options...
durex Posted March 27, 2005 Share Posted March 27, 2005 echo %programfiles% at the command prompt... it should return 'C:\Program Files' (assuming progfiles is on your c drive) so using your syntax youre actually running 'C:\ProgramFilesNortel Networks\Extranet.net'... see the problem?? the syntax you want is WshShell.Run (PROG & "\Nortel Networks\Extranet.exe... Link to comment Share on other sites More sharing options...
Incroyable HULK Posted March 27, 2005 Author Share Posted March 27, 2005 On our computer %ProgramFiles% is located on the D:\ drive...And if I use the suggested syntax, I get an error for this line when I launch the script... I think this has to do with the space between Nortel and Network. Link to comment Share on other sites More sharing options...
durex Posted March 27, 2005 Share Posted March 27, 2005 Regardless of what drive ProgFiles is on, the variable should point to the correct drive. When you get there error, what does it say? and what line does it say it occurs on?Its def not the space in your folder.. vbscript doesnt read in like batch does.. in other words it will look at the entire path and not up until a space like batch does (unless you have it in quotes) Link to comment Share on other sites More sharing options...
gunsmokingman Posted March 27, 2005 Share Posted March 27, 2005 Try This WshShell.Run ( chr(34) & PROG & "Nortel Networks\Extranet.exe -auth 0 -user LOGIN -pwd PASSWORD -serverip 000.000.000.000 -s" &chr(34) ) Link to comment Share on other sites More sharing options...
Incroyable HULK Posted March 27, 2005 Author Share Posted March 27, 2005 In both cases, I get this message:The specified file cannot be found Link to comment Share on other sites More sharing options...
gunsmokingman Posted March 27, 2005 Share Posted March 27, 2005 Here A Test Vbs I Ran And The Code Work On My ComputerAdjust To Your NeedsSet Action = CreateObject("wscript.shell")SysDr =Action.ExpandEnvironmentStrings("%SystemDrive%")Sysdr= SysDr & "\Program Files\ZZ YY XX 123"Action.run (Chr(34) & SysDr & "\Hello It My Cmd Window.cmd" & Chr(34)) Link to comment Share on other sites More sharing options...
Incroyable HULK Posted March 27, 2005 Author Share Posted March 27, 2005 humm... this doesn't work:Set Action = CreateObject("wscript.shell")PROG =Action.ExpandEnvironmentStrings("%ProgramFiles%")Action.run (Chr(34) & PROG & "\test.cmd" & Chr(34))Remember that my Program Files folder is on the D:\ drive... not on C:\ Link to comment Share on other sites More sharing options...
gunsmokingman Posted March 27, 2005 Share Posted March 27, 2005 (edited) So You Know %systemdrive% can be Any Drive Where Windows Is Located So It Does Not Matter, If It C:\ D:\ E:\ F:\ etcWindows Just see The Varible And applies TheProper Location.This Set The LocationSysDr =Action.ExpandEnvironmentStrings("%SystemDrive%")This Add To The Previous VaribleSysdr= SysDr & "\Program Files\ZZ YY XX 123" Edited December 3, 2005 by gunsmokingman Link to comment Share on other sites More sharing options...
Incroyable HULK Posted March 27, 2005 Author Share Posted March 27, 2005 Yes but %SystemDrive% will resolve on C:\ and %ProgramFiles% will resolve on D:\So if I use your code, the result is C:\Program Files\XX YY ZZ ... and that's not correct for me.C:\WindowsD:\Program FilesE:\Documents and SettingsThis is the way our computer are installed... Link to comment Share on other sites More sharing options...
gunsmokingman Posted March 27, 2005 Share Posted March 27, 2005 (edited) For Only D:\Set Action = CreateObject("wscript.shell")SysDr =Action.ExpandEnvironmentStrings("%SystemDrive%")Sysdr= SysDr & "\Program Files\ZZ YY XX 123"'Action.run (Chr(34) & SysDr & "\Hello It My Cmd Window.cmd" & Chr(34))Action.run Chr(34) &"D:\Program Files\ZZ YY XX 123\Hello It My Cmd Window.cmd"& Chr(34)This Will Also WorkAction.run (Chr(34) &"D:\Program Files\ZZ YY XX 123\Hello It My Cmd Window.cmd"& Chr(34)) Edited March 27, 2005 by gunsmokingman 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