Jadog Posted November 17, 2011 Share Posted November 17, 2011 I would like to create a variable and so far I've had no success - I think it's because the folder path is enclosed in quotes. I've tried the following, but when I run it nothing happens: Dim $CPDirectory = "C:\Program Files\RadProg\Bin\" ; If 32-bit PC Run($CPDirectory & '"CP.exe" /Alias "AHOH" /UserID "Backroom" /Workgroup "1"') Here's the one without the variable and it works fine: Run('"C:\Program Files\RadProg\Bin\CP.exe" /Alias "AHOH" /UserID "Backroom" /Workgroup "1"') Link to comment Share on other sites More sharing options...
BrewManNH Posted November 17, 2011 Share Posted November 17, 2011 You're enclosing the program name in quotes, but not the folder name. What that will give you is C:Program FilesRadProgBin"CP.exe" /alias "AHOH"... If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Jadog Posted November 17, 2011 Author Share Posted November 17, 2011 (edited) Ok, so I changed it to: Run('$CPDirectory & "CP.exe" /Alias "AHOH" /UserID "Backroom" /Workgroup "1"') But it still doesn't execute the program. When I remove the outer single quotes and the parameters (see below), then it opens the program just fine. Run($CPDirectory & "CP.exe") I really need it to execute with the specified parameters though. Edited November 17, 2011 by Jadog Link to comment Share on other sites More sharing options...
jbg1978 Posted November 17, 2011 Share Posted November 17, 2011 Try: chr(34) & $CPDirectory & "CP.exe" & chr(34) Link to comment Share on other sites More sharing options...
Malkey Posted November 17, 2011 Share Posted November 17, 2011 Follow the comments in this example. ; Post says this works Run('"C:\Program Files\RadProg\Bin\CP.exe" /Alias "AHOH" /UserID "Backroom" /Workgroup "1"') ConsoleWrite('"C:\Program Files\RadProg\Bin\CP.exe" /Alias "AHOH" /UserID "Backroom" /Workgroup "1"' & @LF) ; So, using this variable Local $CPDirectory = "C:\Program Files\RadProg\Bin\" ; If 32-bit PC ; Next line, we have replaced C:\Program Files\RadProg\Bin\ with ' & $CPDirectory & ' Run('"' & $CPDirectory & 'CP.exe" /Alias "AHOH" /UserID "Backroom" /Workgroup "1"') ConsoleWrite('"' & $CPDirectory & 'CP.exe" /Alias "AHOH" /UserID "Backroom" /Workgroup "1"' & @LF) ; The two resulting console writes are exactly the same. And, these will be the commands that are run. Link to comment Share on other sites More sharing options...
Jadog Posted November 18, 2011 Author Share Posted November 18, 2011 That did the trick. Thank guys! 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