SaintedRogue Posted December 31, 2011 Share Posted December 31, 2011 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 comment Share on other sites More sharing options...
Moderators Melba23 Posted December 31, 2011 Moderators Share Posted December 31, 2011 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. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
SaintedRogue Posted December 31, 2011 Author Share Posted December 31, 2011 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? Link to comment Share on other sites More sharing options...
Developers Jos Posted December 31, 2011 Developers Share Posted December 31, 2011 (edited) try:Run('cmd.exe /k tasklist > "' & $ReportsDir & 'Processes.txt"')Jos Edited December 31, 2011 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 comment Share on other sites More sharing options...
SaintedRogue Posted December 31, 2011 Author Share Posted December 31, 2011 (edited) Woot! There it is! Quotes are so frustrating to me!!! URGH!!! Thanks a million! Edited December 31, 2011 by SaintedRogue Link to comment Share on other sites More sharing options...
clicked Posted January 1, 2012 Share Posted January 1, 2012 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 comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now