Vivaed

Running PS1 Script with Parameters

24 posts in this topic

Trying to automate the sideload of a Windows Store app via .ps1 script...

RunWait(@ComSpec & ' /c' & 'C:\"WB Resources"\APP_Prod\Add-AppDevPackage.ps1')

Above doesn't work... I assume this is trying to open in CMD.

 

Normally we right click the .ps1 and open with powershell, then we have to type "A" to start the install, it installs and then type any yet to exit.
However I cant get the powershell to even open.

Kind of puzzled here, any suggestions would be a help.

PS I also tried to convert the .ps1 to exe, but that was a huge failure... lol

Share this post


Link to post
Share on other sites



We need to use powershell command for running powershell script through command prompt.

Eg:-

powershell "C:\Dummy Directory 1\Foo.ps1"

Share this post


Link to post
Share on other sites

Try this:

ShellExecuteWait('"C:\WB Resources\APP_Prod\Add-AppDevPackage.ps1"')

If it still doesn't work, try it without the outer single quotes around the path and file name. You can't use Run or @ComSpec with a PS script, you need to use ShellExecute. You were also missing the space after /c as well but that wouldn't have helped anyways.


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 Gude
How 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

Share this post


Link to post
Share on other sites
11 minutes ago, BrewManNH said:

You can't use Run or @ComSpec with a PS script

i beg to differ

 

 


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
1 minute ago, iamtheky said:

i beg to differ

 

Beg all you wish, but you are NOT using Run to run the ps1 script, you are using Run to run the powershell program and passing the script name to it. That is a major difference in what the OP was using in his script. Perhaps it would have been clearer to have said "You can't use Run or @ComSpec to directly run a PS script", but my point still stands as accurate.


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 Gude
How 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

Share this post


Link to post
Share on other sites

no its not, you said you cant use X with Y.  When clearly you can, you just must specify the application.  If accurate = misleading then yes, you did great, head pats all around.


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
21 minutes ago, BrewManNH said:

You can't use Run or @ComSpec with a PS script,

Hi Vivaed,

 

You can run powershell script with RunWait command, like we run a powershell script in command prompt.  But ShellExecuteWait can also be used.

 

Thanks

Anoop

Share this post


Link to post
Share on other sites
23 minutes ago, BrewManNH said:

Try this:

ShellExecuteWait('"C:\WB Resources\APP_Prod\Add-AppDevPackage.ps1"')

If it still doesn't work, try it without the outer single quotes around the path and file name. You can't use Run or @ComSpec with a PS script, you need to use ShellExecute. You were also missing the space after /c as well but that wouldn't have helped anyways.

This gets the Shell to open, I see red text with errors but it closes, thanks for the progress!

Share this post


Link to post
Share on other sites
6 minutes ago, Vivaed said:

This gets the Shell to open, I see red text with errors but it closes, thanks for the progress!

What errors you are getting. You may have to set the execution policy.

Share this post


Link to post
Share on other sites
Just now, Anoop said:

What errors you are getting. You may have to set the execution policy.

Not showing, the window closes when it errors, I wish I could pump the output to the console... is that possible?

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

7 minutes ago, Vivaed said:

Not showing, the window closes when it errors, I wish I could pump the output to the console... is that possible?

Can you try with command prompt?

Edited by Anoop

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

14 minutes ago, iamtheky said:

no its not, you said you cant use X with Y.  When clearly you can, you just must specify the application.  If accurate = misleading then yes, you did great, head pats all around.

Are you trying to be pedantic about this, or do you have a point? I said, and I still say, you can't run a ps1 file with Run. You HAVE to use the powershell.exe program to run it. To run it directly without specifying the program you HAVE to use ShellExecute. Where was I wrong in what I wrote before? You can not use Run to directly execute a .ps1 file, so you can't use x with y is 100% accurate if read as it is written and not with a hidden agenda you seem to have.

Edited by BrewManNH

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 Gude
How 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

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

1 hour ago, Anoop said:

Cam you try with command prompt?

Keeps throwing an error about the space between C;\WB and Resources

C:\Windows\System32\WindowsPowerShell>powershell.exe -Command "C:\WB Resources\APP_Prod\Add-AppDevPackage.ps1"
C:\WB : The term 'C:\WB' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and
try again.
At line:1 char:1
+ C:\WB Resources\Wellbeats.Universal_2.2.41.0_Prod\Wellbeats.Universal ...
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\WB:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

# I am running As Admin

# I also triple checked the path and all spelling, everything looked good

Edited by Vivaed

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

sorry, late to the game.  Have you tried wrapping that entire command in single quotes?  If you look at my post you will see i have separated the command, and then you could just call $commmand wrapped in quotes, which also usually works just fine.

something like:

$command = "C:\WB Resources\APP_Prod\Add-AppDevPackage.ps1"

run('powershell.exe -Command ' & '"' & $command & '"')

 

*idk if its chrome or IPB (or a combo) but code boxes are jacked

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
9 minutes ago, iamtheky said:

sorry, late to the game.  Have you tried wrapping that entire command in single quotes?  If you look at my post you will see i have separated the command, and then you could just call $commmand wrapped in quotes, which also usually works just fine.

something like:

$command = "C:\WB Resources\APP_Prod\Add-AppDevPackage.ps1"

run('powershell.exe -Command ' & '"' & $command & '"')

 

*idk if its chrome or IPB (or a combo) but code boxes are jacked

Just tried it, didnt see a window or anything, not sure if even ran, but the app is not installed

Share this post


Link to post
Share on other sites
1 hour ago, BrewManNH said:

You can not use Run to directly execute a .ps1 file, so you can't use x with y is 100% accurate if read as it is written and not with a hidden agenda you seem to have.

I'm not arguing semantics, thats why i quoted you.  Your statement is not accurate. Your revisions are better, but revisionist history is for the badged folk.  You seem to think you need to be right and could not possibly have misrepresented the facts.


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
1 minute ago, Vivaed said:

Just tried it, didnt see a window or anything, not sure if even ran, but the app is not installed

do a cmd /k powershell.exe so you can watch it and we can see the failure


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
5 minutes ago, iamtheky said:

do a cmd /k powershell.exe so you can watch it and we can see the failure

Still barking an error about the space:

C:\WB : The term 'C:\WB' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1
+ C:\WB Resources\Wellbeats.Universal_2.2.41.0_Prod\Wellbeats.Universal ...
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\WB:String) [], CommandNotFou
   ndException
    + FullyQualifiedErrorId : CommandNotFoundException

 

My code:

$iDir = "C:\WB Resources\Wellbeats.Universal_2.2.41.0_Prod\Wellbeats.Universal_2.2.41.0_Prod\Add-AppDevPackage.ps1"

Run('cmd /k C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command ' & '"' & $iDir & '"')

 

I wish I could change the space but we have 2000 systems in the field with this naming convention

Share this post


Link to post
Share on other sites

The -Command parameter is for directly running command strings with PS, not for running scripts with it. Try it without using the -Command parameter.


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 Gude
How 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

Share this post


Link to post
Share on other sites

Use -File instead of -Command.  

 

Adam

 

1 person likes this

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • EdyYusof
      By EdyYusof
      Hi,
      I newbie here, my english not so good
      my first post and first script,
      I learn make sofware with autoit, and to want share with other forumer
      just simple autoit script in my first try
      (and not full follow autoit format(yet, in learning and understand))
      Screenshot  http://www.xyplorer.com/xyfc/download/file.php?id=9726
       
      #include <Array.au3> #include <IE.au3> #NoTrayIcon Global $g_sUrlList, $g_sHelpPath, $g_sNavPath, $g_sKeyword, $hWnd, $g_RegexP Global $sChmUrl_L, $g_sClipbord, $sFileN $sFileN = StringRegExpReplace(@ScriptFullPath, "(.+\\)([^\\]+)\.(au3|a3x|exe)", "$2", 1) $sSDir = StringRegExpReplace(@ScriptFullPath, "(.+\\)[^\\]+\.(au3|a3x|exe)", "$1", 1) Global Const $g_sIniPath = $sSDir & '_IncludePart\' & $sFileN & '.ini' _sClipGet() $sTitl = WinGetTitle("[ACTIVE]") $sExt = StringRegExpReplace($sTitl, "(.+\.)(\w{1,6}).*", "$2", 1) Local $sCount, $sDefault $sCext = "~" $i = 0 $pi = 1 If FileExists($g_sIniPath) = 0 Then _IniWriteSection() Sleep(1000) EndIf If FileExists($g_sIniPath) = 1 Then $j = 0 $sCount = IniRead($g_sIniPath, "MainHChmData", "TotalItems", "") Do $j += 1 $sKeyt = " " & IniRead($g_sIniPath, "HChmData" & $j, "FileExt", "") Until $j = 20 Or $sKeyt = " " $j -= 1 If $sCount <> $j Then IniWrite($g_sIniPath, "MainHChmData", "TotalItems", $j) $sCount = $j EndIf $sDefault = IniRead($g_sIniPath, "MainHChmData", "DefaultItems", "") For $i = 1 To $sCount Local $sCext = " " & IniRead($g_sIniPath, "HChmData" & $i, "FileExt", "") $Cext = StringInStr($sCext, $sExt & ";") If $Cext > 1 Then ExitLoop EndIf Next EndIf If $sCext = "~" Or $sDefault = "" Then $sDefault = 1 If $i > $sCount Then $i = $sDefault $g_sHelpPath = IniRead($g_sIniPath, "HChmData" & $i, "HChmPath", "") $hWndT = '[' & IniRead($g_sIniPath, "HChmData" & $i, "hWnd", "") & ']' $g_sNavPath = IniRead($g_sIniPath, "HChmData" & $i, "ChmUrlList", "") $sDef = IniRead($g_sIniPath, "HChmData" & $i, "DefaultPage", "") $g_RegexP = IniRead($g_sIniPath, "HChmData" & $i, "RegexMatches", "") If FileExists($g_sHelpPath) = 0 Or FileExists($g_sNavPath) = 0 Or $hWndT = "[]" Then MsgBox(0, "Missing Or Invalid Path :", "Note: Make Sure Correct Ini Data In : " & @CRLF & $g_sIniPath & @CRLF & @CRLF & "Bellow Information Data :" & @CRLF & @CRLF & "HelpFile.chm : " & @CRLF & $g_sHelpPath & @CRLF & @CRLF & "ChmUrlList : " & @CRLF & $g_sNavPath & @CRLF & @CRLF & "HelpWindowsHwnd : " & @CRLF & $hWndT & @CRLF) EndIf $sChf = "::" & $sDef If $sDef = "" Then $sChf = "" If WinExists($hWndT) = 0 Then Run('"hh.exe" "' & $g_sHelpPath & $sChf & '"') WinWaitActive($hWndT) Sleep(500) EndIf $hWnd = WinGetHandle($hWndT) If IsHWnd($hWnd) = 0 Then MsgBox(0, "Not Valid Help Windows Hwnd", 'Make Sure Correct Help Windows Hwnd' & @CRLF & @CRLF & "HelpWindowsHwnd : " & @CRLF & $hWndT & @CRLF & @CRLF & "Sample Correct Hwnd (Windows Help Title & Class)" & @CRLF & "REGEXPTITLE:AutoIt Help.+; REGEXPCLASS:HH Parent" & @CRLF & "OR" & @CRLF & "TITLE:AutoIt Help (v3.3.14.2); CLASS:HH Parent") EndIf _sGetUrl() Exit Func _IniWriteSection() If FileExists($g_sIniPath) = 0 Then DirCreate(@ScriptDir & "\_IncludePart") EndIf Local $sAutoItInstallDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & ((@OSArch = 'X64') ? "\Wow6432Node" : "") & "\AutoIt v3\AutoIt", "InstallDir") If $sAutoItInstallDir = "" Then $sAutoItInstallDir = "Replace This Note In _IncludePart\" & $sFileN & ".Ini File With Valid Path " Local $aGeneral[3][2] = [[2, ""], ["TotalItems", "1"], ["DefaultItems", "1"]] Local $aSection[7][2] = [[5, ""], ["HChmPath", $sAutoItInstallDir & "\AutoIt.chm"], ["hWnd", "REGEXPTITLE:AutoIt Help.+; REGEXPCLASS:HH Parent"], _ ["ChmUrlList", @ScriptDir & "\_IncludePart\HHChmAutoIt3.au3t"], ["FileExt", "au3;a3x;"], ["DefaultPage", "html/functions/Window Management.htm"], _ ["RegexMatches", ""]] IniWriteSection($g_sIniPath, "MainHChmData", $aGeneral) IniWriteSection($g_sIniPath, "HChmData1", $aSection) EndFunc ;==>_IniWriteSection Func _sClipGet() $ClipBord = ClipGet() ClipPut("") Sleep(10) Send("^c") $g_sClipbord = ClipGet() ClipPut($ClipBord) Local $iLength = StringLen($g_sClipbord) EndFunc ;==>_sClipGet Func _sGetUrl() Local $iLength = StringLen($g_sClipbord) $aData = StringRegExp($g_sClipbord, '[^"()$\s\n]+', $STR_REGEXPARRAYFULLMATCH) If $aData = 1 Then MsgBox(0, "Abort :", "Clipbord : " & $g_sClipbord & @CRLF & @CRLF & "Noting Selected Or Macth With Regex" & @CRLF & @CRLF) Exit EndIf $g_sKeyword = StringLower(StringFormat("%s", $aData[0])) $iLength2 = StringLen($g_sKeyword) If $iLength2 < 3 Then MsgBox(0, "Note :", "Abort : Word Letter Below 4" & @CRLF & "Seleted = " & $g_sKeyword & @CRLF & "Length = " & $iLength2) Exit Else _aFileRead($g_sNavPath) _sChmUrl() EndIf EndFunc ;==>_sGetUrl Func _sChmUrl() $Reg = '(?i)([^\n]+' & $g_sKeyword & '[^\n]*)' _StringRegex($g_sUrlList, $Reg) $aRegx = "[^\n]+/()\.htm;;[^\n]+/()\w\w?\.htm;;[^\n]+#();;[^\n]+#()\w\w?;;[^\n]+/()[^\n/]+\.htm;;[^\n]+#[^\n#/]*()[^\n]*;;[^\n]+/[^\n/]+()[^\n/]*\.htm;;[^\n]+()[^\n/]*\r" If $g_RegexP <> "" Then $aRegx = $g_RegexP & ";;" & $aRegx EndIf $aRegx = StringSplit("(" & StringReplace(StringReplace($aRegx, "()", $g_sKeyword), ";;", "\r)¦(") & "\r)", "¦", 1) _StringRegexUrl($sChmUrl_L, $aRegx) Exit EndFunc ;==>_sChmUrl Func _NavigateCHM($sFilePath, $sSection) If IsHWnd($hWnd) Then Local $oIE = _IEAttach($hWnd, 'Embedded') _IENavigate($oIE, 'mk:@MSITStore:' & $sFilePath & '::/' & $sSection) WinActivate($hWnd) ; ControlFocus($hWnd,"","[ID:201]") ; ControlClick($hWnd,"","[ID:201]","",1,625, 155) ; ControlClick($hWnd,"","[CLASS:Button; TEXT:Hide;]","") EndIf Exit EndFunc ;==>_NavigateCHM Func _StringRegexUrl($sList, $aRegx) Local $sChmUrl For $i = 1 To $aRegx[0] - 1 $sChmUrl = StringRegExp($sList, '(?i)' & $aRegx[$i], 1) If IsArray($sChmUrl) Then $sChmUrl = StringTrimRight($sChmUrl[0], 1) _NavigateCHM($g_sHelpPath, $sChmUrl) EndIf Next Exit EndFunc ;==>_StringRegexUrl Func _StringRegex($sConten, $Reg) $aGetChmUrl = StringRegExp($sConten, $Reg, 3) If $aGetChmUrl = 1 Then MsgBox(0, "Abort :", "Keyword : " & $g_sKeyword & @CRLF & @CRLF & "Noting Macth Any Chm Url By Keyword" & @CRLF & @CRLF) Exit Else $sCChm = UBound($aGetChmUrl) For $i = 0 To $sCChm - 1 $sChmUrl_L &= $aGetChmUrl[$i] & @CRLF Next EndIf Return $sChmUrl_L EndFunc ;==>_StringRegex Func _aFileRead($g_sNavPath) Local $hFileOpen = FileOpen($g_sNavPath, $FO_READ) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.") Return False EndIf $g_sUrlList = FileRead($hFileOpen) FileClose($hFileOpen) Return $g_sUrlList EndFunc ;==>_aFileRead  
       

      LearningTools.7z
      Info in ReadMe.txt
      Just to ask other forumer,
      Correct way or keyword command to autoit click Hide button in AutoIt.chm windows?
          ControlFocus($hWnd,"","[ID:201]")
          ControlClick($hWnd,"","[ID:201]","left",1)
          ControlClick($hWnd,"","[CLASS:Button; TEXT:Hide;]","left",1)
      I try using ControlClick, sendkey or mouseclick, but not work
       
       
       
      LearningTools.7z
    • nss
      By nss
      Hi all. I am creating an app that runs a program with the admin privileges using the shellexecute's run as verb, but what my problem is, that no matter what I use to launch the program, it doesn't quite work like the run dialog would (certain programs don't get found, etc.). I've tried using the explorer.exe and passing the program to it, that is unreliable and opens documents folder sometimes instead, I've tried using the @comspec /c and that works better, but still some of the programs aren't being found that would be with the run dialog e.g., if I do @comspec /c diskpart it won't find it, I've even tried setting the working dir, but still no luck. I also tried passing commandline params to C:\WINDOWS\system32\rundll32.exe shell32.dll,#61, but no luck. can anyone help me what way to go in order to be able to launch programs in the run dialog style? is there a function in winapi that run dialog uses that I could use as well? Or what would be the best way to go about this? Any help much appreciated.
    • khathiatz
      By khathiatz
      Topic is updating and comeback soon !
       
      UninstallMe will automatically destroy script running
      - With example files
      - Automatic, using file BAT and VBS to destroy, no GUI
       
    • profyt7
      By profyt7
      Hey Guys,
      I am almost there but feel I am missing something that is right in front of me and need another set of eyes.
       
      I am trying to run the following powershell file with the following parameters. This works in powershell just fine.
      Reset-LocalAdminPassword.ps1 -Password $secureString
       
      I created an autoit script to do a few other things but from venturing in the forums I found some code and did the following:
      ;THIS COMMAND WILL RUN THE powershell script
      $iDir = "C:\test\script\Reset-LocalAdminPassword.ps1"
      Run('cmd /k C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File ' & '"' & $iDir & '-Password $secureString')
      Sleep(15000)
       
      The problem is that when it runs it gives me a message that C:\test\script\Reset-LocalAdminPassword.ps1-Password $secureString' is not a valid ps1 file.
      I cannot seem to get it to run the ps1 file with the -Password $secureString' parameter. It keeps cobining the ps1 path and the parameters all as one.
      I am sure this is something I am overlooking but I have been battling with this for a few hours now and just don't know what I am missing.
       
    • Wingens
      By Wingens
      I am trying to send a CTRL+G to a command prompt.
      It should send something like ^G this to the prompt but instead it sends only the G.
      To give more insight into what I am trying to create here:
      At my work we need a programm to open de cashdrawer using the commandprompt, i created a gui where you can set the COM-port to wich the command should be send.
      This works the COM-port setting is writting in a .ini file to be used every time the program opens.
      I have attached the files to the post.
      Hope someone can help me.
       
       
       
      open.zip