+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
Scripts Thread, vbs complex run commands in Coding and Web Development; It's the location of cmd ComSpec=C:\WINDOWS\system32\cmd.exe And, no vbs won't expand it although you could try importing it Set oShell ...
  1. #16
    DMcCoy's Avatar
    Join Date
    Oct 2005
    Location
    Isle of Wight
    Posts
    3,424
    Thank Post
    10
    Thanked 488 Times in 428 Posts
    Rep Power
    111
    It's the location of cmd

    ComSpec=C:\WINDOWS\system32\cmd.exe

    And, no vbs won't expand it although you could try importing it

    Set oShell = CreateObject( "WScript.Shell" )
    comspec=oShell.ExpandEnvironmentStrings("%ComSpec% ")

  2. #17

    Join Date
    Oct 2007
    Location
    Cambridgeshire, UK
    Posts
    306
    Thank Post
    58
    Thanked 23 Times in 20 Posts
    Rep Power
    17
    So if it just runs the cmd.exe, do I really need it? If not then I might as well simplify things again and just use this...

    Code:
    '~~~~~~~~~~~~~~ Set Environment Variables ~~~~~~~~~~~~~~~~
    
    Dim filesys
    Set filesys = CreateObject("Scripting.FileSystemObject")
    Set objShell = CreateObject("Wscript.Shell")
    strApp = "\\server\applications$\Office 2k3\MAINTWIZ.EXE"
    strCfgFile = "\\server\applications$\Office 2k3\UpdateOutlook.CMW"
    strLogFile = "C:\Program Files\Microsoft Office\CMW_Dec08.txt"
    
    '~~~~~~~~~~~~~~ Build Run Command ~~~~~~~~~~~~~~~~~~~~~~~~
    
    CMDLine=Chr(34) & strApp & Chr(34) & " /c " & Chr(34) & strCfgFile & Chr(34) & " /qb-" & " /l " & Chr(34) & strLogFile & Chr(34)
    
    '~~~~~~~~~~~~~~ Check Previous Run State ~~~~~~~~~~~~~~~~~
    
    If Not filesys.FileExists(strLogFile) Then
    
    '~~~~~~~~~~~~~~ Run Command If Necessary ~~~~~~~~~~~~~~~~~
    
    objShell.Run CMDLine, True
    	
    End If

  3. #18
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,998
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106
    %comspec% is special it will work.

  4. #19
    DMcCoy's Avatar
    Join Date
    Oct 2005
    Location
    Isle of Wight
    Posts
    3,424
    Thank Post
    10
    Thanked 488 Times in 428 Posts
    Rep Power
    111
    Quote Originally Posted by ChrisH View Post
    %comspec% is special it will work.
    Hmm, ok then. I didn't know that

    So vbs can't directly use environmental variables *except* comspec because it's different and it makes it harder to remember!

  5. #20
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,998
    Thank Post
    120
    Thanked 280 Times in 258 Posts
    Rep Power
    106
    Quote Originally Posted by DMcCoy View Post
    Hmm, ok then. I didn't know that

    So vbs can't directly use environmental variables *except* comspec because it's different and it makes it harder to remember!
    Thats pretty much it . They should of really made it look like something else but they like to keep us on our toes . If you google it you will find plenty of code without a mention of expanding it.

SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. VBS startup scripts won't run
    By GoldenWonder in forum Windows
    Replies: 2
    Last Post: 10th September 2009, 10:38 PM
  2. Me + The Sims = God complex!
    By Little-Miss in forum Gaming
    Replies: 9
    Last Post: 10th November 2008, 04:23 PM
  3. Replies: 1
    Last Post: 7th December 2007, 07:58 PM
  4. Server 2003 run commands.
    By starscream in forum Wireless Networks
    Replies: 3
    Last Post: 26th June 2007, 10:49 AM
  5. Replies: 4
    Last Post: 7th March 2007, 03:37 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •