Sign in to follow this  
Followers 0
SaintedRogue

Issue Running Commands

6 posts in this topic

Alright, so I'm trying to run a command line option and then save that information to a new folder I created in a variable. So I'm trying to put the variable into the Run argument and it does not seem to be working. I have a feeling it has something to do with the quotations but I just can't seem to figure it out. Here is what I have so far:

;Run script as an administrator.
#RequireAdmin
;Need to find the system date.
#include<date.au3>
;Make a TimeStamp
$TimeStamp = @MON & "-" & @MDAY & "-" & @YEAR
;Create new Directory
DirCreate($TimeStamp)
$ReportsDir = @ScriptDir & "\" & $TimeStamp
;Process Information
Run('cmd.exe /k tasklist > ' & $ReportsDir & '\Processes.txt')

I was thinking that I could just simply create a temp folder as well and then transfer it to the new folder, but I felt like that was the lazy way out and I would like to have it go to the new folder.

Also, does anyone know that with the variable, if it changes date in the middle of the execution of the script if it will create a new folder or error out? Something I should probably test.

Share this post


Link to post
Share on other sites



SaintedRogue,

Do you have spaces in your @ScriptDir which carry over to $ReportsDir? :)

Try putting it in double quotes like this:

Run('cmd.exe /k tasklist > "' & $ReportsDir & '" Processes.txt')

Any better? ;)

As for the date changing mid-script there is no reason why it should error. The result will depend on whether you create the folderpath just once at the beginning of the script (in which case you will keep the same folder) or whether you update it each time you want to use the Run function (when it will create a new folder if the date changes). So you can decide yourself which way you want to go. :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

This is giving me an "Access Denied" error, which I had seen before. Not sure why. I have #RequireAdmin in the script, and I have cmd set to run CMD as an admin.

Any thoughts?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Woot! There it is! Quotes are so frustrating to me!!! URGH!!! Thanks a million!

Edited by SaintedRogue

Share this post


Link to post
Share on other sites

I realize this has been solved, but I have found it often easier to create a temp batch file with the command line and parameters, then perform redirection on the batch file execution. This was the only way I could get redirection to work on scheduled tasks.

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
Sign in to follow this  
Followers 0