Docfxit Posted April 8, 2020 Posted April 8, 2020 (edited) I have a .bat file that works: "C:\Program files\Client Access\cwblogon.exe" 70.235.xxx.xxx /u quser /p userpassword I don't want to use the bat file because it shows the password in plain text. I created this script to replace it: #include "OSVersion.au3" _OSVersion() #RequireAdmin MsgBox(16, "Path:", $ProgramFiles & "Client Access\cwblogon.exe") RunWait('$ProgramFiles & "Client Access\cwblogon.exe" 70.235.xxx.xxx /u quser /p userpassword', '') Sleep(1000) Exit I run the script compiled. I can see when the bat file runs in a cmd window that it runs fine. When the AutoIt script runs the MsgBox shows the correct path but it doesn't show me the same log that the bat file shows. I don't see a window opening up besides the MsgBox. What could I be doing wrong? Thank you, Docfxit Edited April 8, 2020 by Docfxit
Subz Posted April 8, 2020 Posted April 8, 2020 Shouldn't it be: RunWait('"' & $ProgramFiles & 'Client Access\cwblogon.exe" 70.235.xxx.xxx /u quser /p userpassword', '')
Musashi Posted April 8, 2020 Posted April 8, 2020 8 minutes ago, Docfxit said: I don't want to use the bat file because it shows the password in plain text. @Subz is right (of course ). You added the variable $ProgramFiles into the string. BTW : Passwords within an AutoIt script are also not very secure. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
Docfxit Posted April 8, 2020 Author Posted April 8, 2020 I don't have computer geniuses. This compiled version has worked for years. I'm not worried about someone hacking an Autoit compiled object. Thanks, Docfxit
Docfxit Posted April 8, 2020 Author Posted April 8, 2020 (edited) I'm still getting an error with this: RunWait(" '"' & $ProgramFiles & Client Access\cwblogon.exe" 70.235.xxx.xxx / u quser / p userpassword", ' ', @SW_HIDE) "C:\Dnload\9xAddons\AS400SignOn.au3"(9,101) : error: syntax error Edited April 8, 2020 by Docfxit
Subz Posted April 8, 2020 Posted April 8, 2020 (edited) Can you post your entire script, it seems as thought /u and /p are being seen as functions. Did you copy and paste the code I used above? The forum has a bug (sometimes) where it adds hidden characters into the posts, so use F5 in Scite and see if it detects the hidden character in the console. You could also use the following to get Program File Dir using this: #RequireAdmin Global $g_sProgramFilesx64 = @OSArch = "x64" And @AutoItX64 = False ? RegRead("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir") : @ProgramFilesDir MsgBox(16, "Path:", $g_sProgramFilesx64 & "\Client Access\cwblogon.exe") RunWait('"' & $g_sProgramFilesx64 & '\Client Access\cwblogon.exe" 70.235.xxx.xxx /u quser /p userpassword') Edited April 8, 2020 by Subz
Docfxit Posted April 8, 2020 Author Posted April 8, 2020 #include "OSVersion.au3" _OSVersion() #RequireAdmin MsgBox(16, "Path:", $ProgramFiles & "Client Access\cwblogon.exe") RunWait(" '"' & $ProgramFiles & Client Access\cwblogon.exe" 70.235.xxx.xxx / u quser / p userpassword", ' ', @SW_HIDE) Sleep(1000) Exit OSVersion.au3 ;AutoIt_Debugger_Command:Disable_Debug #include <AutoItConstants.au3> If _OSVersion() = 'Win7' Or _OSVersion() = 'Win_7SP1' Or _OSVersion() = 'Win7X64' Or _OSVersion() = 'Win7SP1x64' Then $ProgramFiles = "C:\Programs\" Else $ProgramFiles = "C:\Program Files\" EndIf If Not (FileExists($ProgramFiles & "Client Access")) Then $ProgramFiles = "C:\Program Files\IBM\" EndIf If Not (FileExists($ProgramFiles & "Client Access")) Then $sMessage = "Client Access NOT Found." SplashTextOn("Title", $sMessage, -1, 100, -1, -1, $DLG_TEXTLEFT, "", 34) Sleep(3000) SplashOff() EndIf ; MsgBox("", "Test", "_OSVersion = " & _OSVersion()) Func _OSVersion() Global $OS_Version, $servicepack_version Local $sWinVer = FileGetVersion('winver.exe') $OS_Version = @OSVersion $servicepack_version = StringReplace(@OSServicePack, "Service Pack ", "SP") If @error = -1 Then $servicepack_version = "" ConsoleWrite($OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '') & @CRLF) ConsoleWrite(@OSArch & @CRLF) Return $OS_Version & $servicepack_version & StringRegExpReplace(@OSArch, '(X86)', '') ;AutoIt_Debugger_Command:Enable_Debug EndFunc ;==>_OSVersion
Subz Posted April 8, 2020 Posted April 8, 2020 (edited) Couldn't you just use something like: #RequireAdmin ;~ Get Program Files Directory from Registry if OS = 64-bit and script has not been 64-bit compiled Global $g_sProgramFilesDir = @OSArch = "x64" And @AutoItX64 = False ? RegRead("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir") : @ProgramFilesDir ;~ Set Program Files Path Global $g_sProgramFiles = FileExists($g_sProgramFilesDir & "\Client Access") ? $g_sProgramFilesDir : $g_sProgramFilesDir & "\IBM" ;~ Check if Client Access path exists If Not FileExists($g_sProgramFiles & "\Client Access") Then SplashTextOn("Title", "Client Access NOT Found.", -1, 100, -1, -1, 4, "", 34) Sleep(3000) Exit EndIf MsgBox(16, "Path:", $g_sProgramFiles & "\Client Access\cwblogon.exe") RunWait('"' & $g_sProgramFiles & '\Client Access\cwblogon.exe" 70.235.xxx.xxx /u quser /p userpassword', "", @SW_HIDE) Edited April 8, 2020 by Subz
Musashi Posted April 8, 2020 Posted April 8, 2020 10 minutes ago, Subz said: Sleep(3000 ) missing Subz 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
Docfxit Posted April 8, 2020 Author Posted April 8, 2020 (edited) 18 minutes ago, Subz said: Couldn't you just use something like: #RequireAdmin ;~ Get Program Files Directory from Registry if OS = 64-bit and script has not been 64-bit compiled Global $g_sProgramFilesDir = @OSArch = "x64" And @AutoItX64 = False ? RegRead("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir") : @ProgramFilesDir ;~ Set Program Files Path Global $g_sProgramFiles = FileExists($g_sProgramFilesDir & "\Client Access") ? $g_sProgramFilesDir : $g_sProgramFilesDir & "\IBM" ;~ Check if Client Access path exists If Not FileExists($g_sProgramFiles & "\Client Access") Then SplashTextOn("Title", "Client Access NOT Found.", -1, 100, -1, -1, 4, "", 34) Sleep(3000 Exit EndIf MsgBox(16, "Path:", $g_sProgramFiles & "\Client Access\cwblogon.exe") RunWait('"' & $g_sProgramFiles & '\Client Access\cwblogon.exe" 70.235.xxx.xxx /u quser /p userpassword', "", @SW_HIDE) It didn't run. I added MsgBox above If not #RequireAdmin ;~ Get Program Files Directory from Registry if OS = 64-bit and script has not been 64-bit compiled Global $g_sProgramFilesDir = @OSArch = "x64" And @AutoItX64 = False ? RegRead("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir") : @ProgramFilesDir ;~ Set Program Files Path Global $g_sProgramFiles = FileExists($g_sProgramFilesDir & "\Client Access") ? $g_sProgramFilesDir : $g_sProgramFilesDir & "\IBM" ;~ Check if Client Access path exists MsgBox(16, "Path:", $g_sProgramFiles & "Client Access\cwblogon.exe") If Not FileExists($g_sProgramFiles & "\Client Access") Then SplashTextOn("Title", "Client Access NOT Found.", -1, 100, -1, -1, 4, "", 34) Sleep(3000) Exit EndIf MsgBox(16, "Path:", $g_sProgramFiles & "\Client Access\cwblogon.exe") RunWait('"' & $g_sProgramFiles & '\Client Access\cwblogon.exe" 70.235.xxx.xxx /u quser /p userpassword', "", @SW_HIDE) On the MsgBox I added I'm getting: False\IBMClient Access\cwblogon.exe Thanks for the suggestion: Docfxit PS: This test is not running in 64bit. I tried removing & '\IBM" and I get FalseClient Access\cwblogon.exe Edited April 8, 2020 by Docfxit
Subz Posted April 8, 2020 Posted April 8, 2020 So is the OS 32-bit or 64-bit? It seems that the issue is with $g_sProgramFilesDir can you try this: Global $g_sProgramFilesDir = @OSArch = "x64" ? RegRead("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir") : @ProgramFilesDir
Docfxit Posted April 8, 2020 Author Posted April 8, 2020 I have changed the original script and it runs. But it doesn't fix the problem. The bat file works but this doesn't work: #include "OSVersion.au3" _OSVersion() #RequireAdmin MsgBox(16, "Path:", $ProgramFiles & "Client Access\cwblogon.exe") RunWait('"' & $ProgramFiles & 'Client Access\cwblogon.exe" 70.235.xxx.xxx / u quser / p userpassword', "", @SW_HIDE) Sleep(1000) Exit Is there a way to show the same output I get in the cmd window so I might see what the problem is?
Docfxit Posted April 8, 2020 Author Posted April 8, 2020 (edited) 5 minutes ago, Subz said: Remove the @SW_HIDE I have removed @SW_HIDE It runs. I don't see the output that I see with the bat file. It doesn't solve the problem. So I think the output will tell me what is wrong. Thanks, Docfxit PS: I have run the AutoIt before and it ran successfully. I wonder if it needs to be changed to run with cmd? Edited April 8, 2020 by Docfxit
Subz Posted April 8, 2020 Posted April 8, 2020 You can try using: RunWait(@ComSpec & ' /k "' & $g_sProgramFiles & '\Client Access\cwblogon.exe" 70.235.xxx.xxx /u quser /p userpassword')
Docfxit Posted April 9, 2020 Author Posted April 9, 2020 I have it working. You were a really great help. Thank you very very much. 🙂 Docfxit
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