Jump to content

Recommended Posts

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.

Link to post
Share on other sites
  • Moderators

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

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 post
Share on other sites
  • Developers

try:

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

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...