Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Using SchTasks in vbScript

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,34387
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Using SchTasks in vbScript
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Using SchTasks in vbScript - 5/11/2006 6:00:25 AM   
  UnderCoverGuy

 

Posts: 2
Score: 0
Joined: 5/11/2006
Status: offline
OK, I am trying to use SCHTASKS in a vbScript.  However, I need to use spaces in my path, since JohnDo~1 may refer to "John Doe" or "John Doeboy", depending which was installed first.  How would I setup this line?  The /norun below would signify command-line arguments.  The double-quote thing never works and I tried triple-quotes but that didn't run either.

*********************************************

LaunchCommand = "SchTasks /create /tn ""Comment"" /tr ""C:\Program Files\App.Exe /norun"" /sc once /st " & NewTime & " /sd " & NewDate & " /ru " & InstallAccount & " /rp " & InstallPassword
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec(LaunchCommand)

*********************************************

Any help would be appreciated.

THANKS!


 
 
Post #: 1
 
 RE: Using SchTasks in vbScript - 5/11/2006 6:20:34 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
I hate double quoting in VBScript. Here is how I approach any double quoting problem. First determine what command would do what you want from the command line. Next write a script that has 2 and only 2 lines in it (well 4 lines if you want to use Option Explicit). The 2 lines will be:

strCmd = "THIS IS SOME COMMAND THAT YOU WANT TO RUN"
WScript.Echo strCmd

Obviously you will need to tweak that first line a bit. Now play around with double quoting until you get what you want to display correctly. Copy and paste into the script where you want to use it. I realize this is not a particularly palatable solution, but it is the only way that I have found that will always eventually wind up with the correct answer. There are some people around that can just look at a string and spot exactly where to use multiple quotes. I just don't happen to be one of them. There are also functions floating around that claim to do proper double quoting for you, but I have never found one that works to my satisfaction.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to UnderCoverGuy)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Using SchTasks in vbScript Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts