Jump to content

Running a Command not finding PATH


Recommended Posts

OK, so I am trying to run a command. But, it seems that I'm not finding the proper path. The tool that needs to run is in a folder in the ScriptDir. But I cannot seem to be able run anything in that folder. It seems like I have everything right, but I'm not sure. Are my quotations messed up, maybe?

Here is the code:

if(GuiCtrlRead($SysInfo)  = 1) then
    ; Gather System Information
  RunWait(@ComSpec & ' /c systeminfo > "' & $ReportsDir & '\System Info.txt"')
  RunWait(@ComSpec & ' /c "' & @ScriptDir & '\SysinternalsSuite\psinfo -accepteula >> "' & $ReportsDir & '\System Info.txt"')
EndIf

Ideas/Thoughts?

Link to comment
Share on other sites

  • Moderators

SaintedRogue,

No promises, but try this:

RunWait(@ComSpec & ' /c "' & @ScriptDir & 'SysinternalsSuitepsinfo -accepteula" >> "' & $ReportsDir & 'System Info.txt"')

I always use ConsoleWrite to check long command strings like this to make sure of the quotes. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

M23,

No such luck. I send the command to a MsgBox() and I see the right output. I even put it into a command prompt and it worked... but it's not working in the script for some reason. Maybe I cannot use 2 run commands?

Edited by SaintedRogue
Link to comment
Share on other sites

  • Moderators

SaintedRogue,

So write out what you would have to enter at the command prompt to run corerctly and then use ConsoleWrite on the string to see if you are getting what you need. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

SaintedRogue,

The string you posted initially has only 3 double-quotes - I doubt that is what you want: :)

C:Windowssystem32cmd.exe /c "M:ProgramAu3 ScriptsSysinternalsSuitepsinfo -accepteula >> "M:ProgramAu3 ScriptsSystem Info.txt"
                               1                                                               2                                      3

I used @ScriptDir twice as I do not know what your $ReportsDir shoudl be. ;)

I added a fourth - but perhaps in the wrong place:

C:Windowssystem32cmd.exe /c "M:ProgramAu3 ScriptsSysinternalsSuitepsinfo -accepteula" >> "M:ProgramAu3 ScriptsSystem Info.txt"
                               1                                                           2    3                                      4

Are you sure you see what you need in that MsgBox rather than what you want to see? :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Sorry, I should have clarified. Your additional quote does make it right, that's what I was then using when I said I was seeing what I want to. And it should work. If I were to copy the command that I outputted in MsgBox, into CMD the command executes. However, it fails without it. I flagged CMD to /k rather than /c and see that it seems to be an issue with the argument. But the argument is correct and again works if I type it in afterwards.

Probably shouldn't use MsgBox(), but I'm a newb and it's the easiest thing for me to see the command. Not really sure how to use ConsoleWrite, honestly.

Link to comment
Share on other sites

what is the output of consolewrite ?

;~ if(GuiCtrlRead($SysInfo)  = 1) then
    ; Gather System Information
  _RunWait(@ComSpec & ' /c systeminfo > "' & @ScriptDir & '\System Info.txt"')
  _RunWait(@ComSpec & ' /c "' & @ScriptDir & '\SysinternalsSuite\psinfo" -accepteula >> "' & @ScriptDir & '\System Info.txt"')
;~ EndIf
Func _RunWait($var)
ConsoleWrite($var & @CRLF)
RunWait($var)
EndFunc
Link to comment
Share on other sites

  • Moderators

SaintedRogue,

If you run your code in SciTE then ConsoleWrite will output into the lower pane of the editor - a very useful little tool. ;)

Given your further explanation on how the "correct" string fails I am at a loss as to how I might help any more. Sorry. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Yeah, I'm not sure either. Seems to be an issue with the program I'm trying to run. I'll have to play. :) It's frustrating, because if I put CMD in that folder and then run it, with something like this:

RunWait('cmd.exe /c .SysinternalsSuitepsservice -accepteula >> "' & $ReportsDir & 'Services.txt"')

It works everytime. But doing that I have to have CMD in the folder and I think that's kind of lazy. I wanted to see if I could find a way around it.

Thank you very much for your input, M23.

Edited by SaintedRogue
Link to comment
Share on other sites

  • Moderators

SaintedRogue,

So what does @ComSpec come up as when you do this: :)

ConsoleWrite(@ComSpec & @CRLF)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hey! ConsoleWrite is pretty handy!

I get: C:\Windows\System32\cmd.exe

So the command ran, is : C:\Windows\System32\cmd.exe /k "C:UsersAhrendtDocumentsForensicIRSysinternalsSuitepsinfo -s -d -accepteula" > "C:UsersAhrendtDocumentsForensicIR01-04-2012 ReportsSystem Info.txt"

Link to comment
Share on other sites

  • Moderators

SaintedRogue,

Well at least I showed you something out of all this! :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • 11 years later...

I know this is old but since google led me here when I had a similar issue and nothing else matched, I thought I'd mention the solution in my case. The program I was trying to use in my case wasn't on the path, but I didn't remember to restart SciTE after I added it. So every time SciTE launched my script my script would then launch CMD with an outdated path. hope this helps.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...