Search the Community
Showing results for tags 'ComSpec'.
-
This is the AutoIt script I'm using: #include <AutoItConstants.au3> Local $Python = "C:\Program Files\Python38" Local $Script = "levenstein.py" Local $String1Path = @ScriptDir & "\string1.txt" Local $String2Path = @ScriptDir & "\string2.txt" Local $Arguments = '"' & $String1Path & '" "' & $String2Path & '"' Local $Concat = $Script & " " & $Arguments ConsoleWrite(@CRLF & $Concat) Local $RunIt = Run(@ComSpec & " /c " & $Concat, @ScriptDir, @SW_HIDE, $STDERR_MERGED) $Output = StdOutRead($RunIt) ConsoleWrite(@CRLF & "Output:" & $Output) It calls the following Python script (levenstein.py): import re import sys import editdistance def main(): # Check if there are 2 command line arguments if len(sys.argv) != 3: print("Error: Two file paths must be provided") return # Read the contents of the files filepath1 = sys.argv[1] filepath2 = sys.argv[2] string1 = read_file_contents(filepath1) string2 = read_file_contents(filepath2) # Calculate and print the similarity between the two strings similarity = calculate_similarity(string1, string2) print(similarity) def read_file_contents(filepath): # Read the contents of a file into a string with open(filepath, 'r') as f: return f.read() def calculate_similarity(string1, string2): # Calculate the similarity between two strings return 100 - (100 * editdistance.eval(string1, string2) / max(len(string1), len(string2))) # Run the main function if __name__ == '__main__': main() It's working when I run it from cmd, but not when I use AutoIt. My AutoIt console looks like this: levenstein.py "C:\test\Autoit Python\string1.txt" "C:\test\Autoit Python\string2.txt" Output: Whereas when I run the exact same command in cmd levenstein.py "C:\test\Autoit Python\string1.txt" "C:\test\Autoit Python\string2.txt" I get an output that's more like 77.08934 which is what I would expect from the .py script. I believe I must be making a mistake in the way I'm using the Run command. Note: I'm using Python for Edit Distance because the files I'm comparing are rather large, and I'm not sure if the code snippets I found in the Autoit forum would be effective.
- 10 replies
-
Hope someone can help as quotes within quotes is always confusing. I am creating a silent install of printer software and want to call via runwait comspec line. The call within a cmd line is below samsung.exe /s /n"Samsung SL-M3220ND" /p"xxx" xxx will be stored as a variable $PrinterIP which would be as example 10.10.10.20 I need to use a variable as i am doign this for a business and need it to be based on the store i install at that has a specific IP range. I started with the below as 2 possibilities but no luck.. RunWait(@ComSpec & "/c " & "samsung.exe /s /n""Samsung SL-M3220ND"" /p""" & $PrinterIP ") RunWait(@ComSpec & "/c " & "samsung.exe /s /n'Samsung SL-M3220ND' /p'" & $PrinterIP '") but i cant get it to compile as i have errors on the line.. thanks in advance.
-
Good morning AutoIt community! Today, I'm here to ask you if you know how to run an .exe from cmd.exe ( Command Prompt )... My intention is to read a .ini file where I store an information that has to be included in the shell, and run an .exe with that information... I'll give you an example Local $aFileCartellaAuditCopy = _FileListToArray($sPercorsoAuditCopy, "*.txt") If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante la lettura della lista dei file nella directory" & @CRLF & $sPercorsoAuditCopy & @CRLF & "Errore: " & @error) Return False Else Local $iPID = Run("cmd.exe" & ' /k "C:\Users\Portatile-60\Desktop\HmiCheckLogIntegrity.exe" "C:\Users\Portatile-60\Desktop\AuditTrailDosaggio0_20170327_151335_DOSAGGIO_PW_01.txt"') ; & " /k " & '"' & $sHmiCheckLogIntegrity & '"' & " " & '"' & $sPercorsoAuditCopy & "\" & $aFileCartellaAuditCopy[1] & '"', "", @SW_SHOW, $STDOUT_CHILD) Return True EndIf This code is in a function, that returns False if it can retrive at least a file from the path stored in the .ini file... Else I would like to run the Command Prompt with the .exe and with a parameter of that .exe, but it seems to not work properly. Could please anyone tell me why? Thanks
-
Hi guys, This is probably an obvious one, but I really don't use this command at all so am hoping you can spot my mistake. I'm running a powershell script on a schedule with the following script in a function, the function is being called in a loop, but the console process is not closing in the background and I end up with a bunch of console windows running in the background: Run(@comspec & ' /k PowerShell.exe -STA -NonInteractive -ExecutionPolicy ByPass -Command "& ''Z:\Powershell\365\GetNextDetails.ps1'' "', "", @SW_HIDE) Thanks!
-
Hello, I've some troubles whit the run command. Below u see 2 command's , 1 is working and the other not. (the first isn't working) I think the problem is in te space between program and files.Also I've treid every thing i could think of or the helpfiles handed to me. (or maybe I din't find the correct answer:)) I tried so mush that i don't know anymore if it's the space between program files or not. Could somebody point me in the right direction? Not working: Run(@ComSpec & " /c psexec -i \\127.0.0.1 -u username -p pass -h -d /accepteula C:\Program Files\some_prog\Shell.exe" ,"C:\tools", @SW_HIDE) Working : Run(@ComSpec & " /c psexec -i \\127.0.0.1 -u username -p pass /accepteula cmd" , "C:\tools" , @SW_HIDE)
-
hello, I'm trying to make a check if a process is running on a remote PC. This is what i got this far when I edit a found snippet on this forum. The function _CMDreturn returns the output of the command line command. In this output I want to scan if there is a line whit "process mspaint was not found". This I'm trying to do whit StringLeft. The problem is that I don't get any error's and also don't get a message if it doesn't exist. Could somebody say to me what I'm doing wrong here? Or iff there is a better way to do this? Thanks in advanced. #include <Constants.au3> $result= _CMDreturn('C:\Tools\Ps\pslist.exe mspaint') msgbox(0,"Version",$result) Func _CMDreturn($sCommand) $cmdreturn = "" $stream = Run(@ComSpec & " /c " & $sCommand, @SystemDir, @SW_HIDE, $STDOUT_CHILD + $STDIN_CHILD) While 1 $line = StdoutRead($stream) If @error Then ExitLoop If StringLeft($line, 32) = "process mspaint was not found on" Then msgbox(0,"not found",$line) EndIf $cmdreturn &= $line WEnd Return $cmdreturn EndFunc
-
Hi, I want to install chocolatey (https://chocolatey.org/) with AutoIt. I just need to send the following command to cmd: @powershell -NoProfile -ExecutionPolicy unrestricted -Command "(iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))) >$null 2>&1" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\binThis is what I tried: RunWait(@ComSpec & " /C " "@powershell -NoProfile -ExecutionPolicy unrestricted -Command "(iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))) >$null 2>&1" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin", "");It didn't work propably because of the quotes. So I tried this: $code1 = "@powershell -NoProfile -ExecutionPolicy unrestricted -Command" $code2 = " (iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))) >$null 2>&1" $code3 = " && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" RunWait(@ComSpec & " /C " & $code1 & $code2 & $code3, "");Didn't work either. Any help? Thanks in advance =)
- 4 replies
-
- chocolatey
- cmd
-
(and 3 more)
Tagged with:
-
Hello everyone, I'm working on a WMIC uninstaller. A quite simple one with a button to display product names in a editable list (for copy/paste purposes) but the main problem is that in order to achieve this, in my corporation, normal users cannot uninstall softs. What I found/adapt so far: #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("wmic uninstaller", 300, 152, 337, 380) $Label1 = GUICtrlCreateLabel("Computername", 0, 8, 75, 17) $Input1 = GUICtrlCreateInput(@ComputerName, 0, 32, 125, 21) $Label2 = GUICtrlCreateLabel("wmic command", 150, 8, 77, 17) $Combo1 = GUICtrlCreateCombo("Model_Computer", 150, 32, 125, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Current_user|Installed_Apps|Serial_Number|Bios_Version") $Button1 = GUICtrlCreateButton("List Apps", 150, 72, 91, 49) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $button1 $wmi = GUICtrlRead($combo1) $pc = GUICtrlRead($input1) call($wmi,$pc) EndSwitch WEnd Func Model_Computer($pc) RunWait(@ComSpec & ' /c ' & 'wmic /node:' & $pc &' product get name > %temp%\apps.txt' ,"", @SW_HIDE) $file=(@TempDir & "/apps.txt") $fileread= FileRead($file) MsgBox(0, $pc , $fileread) FileDelete(@TempDir & "/apps.txt") EndFunc Here's the textual version I gave to my techs: Create cmd shortcut on Desktop, run it as a different user (using their own admin accounts).Once opened, type wmicOnce wmic loaded, type product get nameWait for the list of installed soft to displayType product where name="Exact App name" call uninstallType "Y" to confirmWait for task executionDon't care about exit codeApp is uninstalled (verified by getting the list again)!In fact, I'd like to automatize this process. Any ideas over here? Thanks ^^
-
Hi guys, I have this batch file that run the following code and it work fine. C:\Windows\System32\cmd.exe /C set __COMPAT_LAYER=RunAsInvoker & start "" "C:\Program Files\test 123\test 123.exe" but I'm trying to use autoit @comspec to compile it to a executable file. I'm having problem with the syntax. Can anyone be kind enough to guide me. This is the @comspec code I try. RunWait(@Comspec & ' /c set __COMPAT_LAYER=RunAsInvoker ' & 'start' & 'C:\Program Files\test 123\test 123.exe')
-
I'm using my script to monitor established connections with the network. I'm using combination of RUN and NETSTAT command, however, constantly calling netstat from CMD doesn't feel elegant enough, and it's causing my script to perform really slow. Is there more elegant solution, an alternative for calling netstat?
-
It doesn't seem that I can run Sysprep in Windows 8 RP x64 using @ComSpec. I have no problem running other apps using either Run() or RunWait() in the same app. I am testing in Audit Mode (Administrator account, UAC is disabled). I already searched the forums and didn't find any one else trying to execute Sysprep like this... This does not work when run compiled: Run ( @ComSpec & " /c c:\windows\system32\sysprep\sysprep.exe /oobe /shutdown") Returns error "is not recognized as an internal or external command, operable program or batch file." I don't know how to keep the ComSpec window open, so the only way for me to see this was to hold down the Enter key so I could see the error. Curiously, running this manually works fine: cmd.exe /c c:\windows\system32\sysprep\sysprep.exe /oobe /shutdown App is compiled for x86. OH! Do not try to run this on your workstation!!!
-
Can't make it work when spaces are in the directory names. Tried the following: FYI (c:tempnew folder) is a @ScriptDir CMD DOS (batch) WORKS "c:tempMy Folderappspsloglist.exe" -accepteula -d 14 Application > "c:tempmy Folderout12.txt" AutoIT Does Not RunWait(@ComSpec & ' /c "'&@ScriptDir&'appspsloglist.exe" -accepteula -d 14 Application > "'&@ScriptDir&'out12.txt"','',@SW_SHOWNORMAL) Please help
-
Can't make it work when spaces are in the directory names. Tried any possible quotations.. All my directories and script in "My Documents" Your help will be appreciated!! Global $ToolPath = @ScriptDir&"\Myutility" ;;;; \My Documents\main.au3) Global $myoutput = $ToolPath&"\output" Global $appspath = $ToolPath&"\apps" Global $foldertochecksum = @ProgramFilesDir $runme = @ComSpec & ' /c ' & $appspath&'\md5sums.exe -n -e -b' & ' ' &$foldertochecksum& ' > ' & $myoutput&'\out.txt' msgbox(0,"",$runme) RunWait($runme,"",@SW_HIDE)
-
It's Weird. I think I don't get it. Why it doesn't work like it is supposed to? I need to create a Script to monitor one of our fileservers to check how many users and what users opens how many .EXEs at this server. The DOS command to do that is simple: openfiles /query /FO table /V /nh | find /I ".exe" > exportx.log The DOS command typed at it's prompt. The report out is something like that (and exactly what I need AutoIt to run from 30 to 30 minutes): [text] SERVER80 3487273 JULIAN Windows 0 Read R:\PWD\PWD_APP\rpc.exe SERVER80 5644134 WELTON Windows 0 Read R:\SUPORT\Gho11\Gho5.Exe SERVER80 6251031 DARLEYMX Windows 0 Read R:\DEVELOPMENT\APPS\Applications.S.Winform.exe SERVER80 6591869 ELCIOVS Windows 0 Read R:\SUPORT\Prog\VC\vcvw.exe SERVER80 7984711 SANDREO Windows 0 Read R:\SUPORTE\UTILITARIOS\WinStress\WinStress.exe SERVER80 8399253 BRIANB Windows 0 Read R:\DEVELOPMENT\FONTS\PGCD\APGC.exe [/text] Okay, so, as I've used before with other DOS commands, I inserted that command into a @compsec line, But it just won't work. If you read below there, you'll see how many different attempts I tried. No success. If Not FileExists(@ScriptDir & "\Export") Then DirCreate(@ScriptDir & "\Export") EndIf Global $Hour = "_" & @HOUR & "'" & @MIN & "''" Global $Date = @YEAR & "-" & @MON & "-" & @MDAY Global $FullDate = $Date & "_" & $Hour Global $ReportOut = $FullDate & "_" & IniRead("Config.ini", "ReportOut", "ReportOut", "Report") Global $ReportDir = @ScriptDir & "\Export\" Global $FilterExt = IniRead("Config.ini", "FilterExt", "FilterExt", "N") Global $FileExt = '".' & IniRead("Config.ini", "FileExt", "FileExt", "exe" & '"') Global $FormatOut = IniRead("Config.ini", "FormatOut", "FormatOut", "Table") Global $QueryCommand = "/query " & "/FO " & $FormatOut & " /V " & "/nh " Global $FindCommand = "| find /I " & $FileExt Global $ExportCommand = " > " & $ReportOut & ".log" Global $CommandCombo If $FilterExt = "Y" Then $CommandCombo = $QueryCommand & $FindCommand & $ExportCommand Else $CommandCombo = $QueryCommand & $ExportCommand EndIf ;openfiles /query /FO table /V /nh | find /I ".exe" > exportx.log <--- Command to be used: ;/query /FO '& $FormatOut &' /V /nh | find /I "' & $Extension & '" > ' & $ExportFile & '" "' ;Local $PID = RunAs("adm-user", "DomainX", "P@ssW0rDX", 4, Run(@ComSpec & "/c openfiles /query /FO table /V /nh | find " & $FileExt & " > exportx.log", @ScriptDir), @ScriptDir) ; <--- The entire command. Didn't work ;local $PID = RunAs("adm-user", "DomainX", "P@ssW0rDX", 4, Run(@ComSpec & "/c openfiles " & $CommandCombo & " ", @ScriptDir), @ScriptDir) ; <--- Narrowed down the arguments to a single variable. Didn't work Local $PID = RunAs("adm-user", "DomainX", "P@ssW0rDX", 4, Run(@ComSpec & "/c openfilescommandline.bat", @ScriptDir), @ScriptDir) ; It was created a bat file that works when executed manually, but doesn't when executed through @comspec MsgBox(0, "", $CommandCombo) Local $pidreal = StdoutRead($PID) MsgBox(0, "", $pidreal) FYI, The ini file is as follows: [FilterExt] FilterExt = Y [FileExt] #FileExt = ".exe" [ReportOut] ReportOut = _Report [FormatOut] FormatOut = table Can anyone tell me what is my sin? Thanks in advance.