# Need help writting a Windows script file

**URL:** <https://boards.straightdope.com/t/need-help-writting-a-windows-script-file/333523>\
**Category:** Factual Questions\
**Created:** [December 1, 2005, 5:32am UTC](https://boards.straightdope.com/t/need-help-writting-a-windows-script-file/333523 "2005-12-01T05:32:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nobody](https://avatars.discourse-cdn.com/v4/letter/n/94ad74/32.png) [@Nobody](https://boards.straightdope.com/u/Nobody)\
**Post date:** [December 1, 2005, 5:32am UTC](https://boards.straightdope.com/t/need-help-writting-a-windows-script-file/333523/1 "2005-12-01T05:32:04Z")

</div>

So, I wanted to be able to control which order programs load when windows starts up.  
I have a program called Startup.exe which shows which programs load on startup, and can let you choose to load, or not load them. You can also edit the parameters.  
I also found a script StartupDelay.vbs which lets you load programs in the order you want, and have a delay to keep too many things from loading at once. Here’s the unmodified code

SecondsToDelay = “5”  
ProgramToRun = “iexplore” 'may need full path  
Wscript.Sleep(SecondsToDelay \* 1000)  
Prog = Chr(34) & ProgramToRun & Chr(34)  
CreateObject(“WScript.Shell”).Run(Prog)

Ok here’s the path of one of the programs I want to run

“H:\Program Files\RAMpage\RAMpage.exe” M=100 T=600 A D=Y P=“H:\Program Files\RAMpage\RAMpageConfig.exe”

So how can I make ProgramToRun equal this path and parameters?

I’ve tried quoting it different ways, and so far, no success. Thank you.

---

<div class="post-metadata">

**Author:** ![ishamael69](https://avatars.discourse-cdn.com/v4/letter/i/b9e5f3/32.png) [@ishamael69](https://boards.straightdope.com/u/ishamael69)\
**Post date:** [December 1, 2005, 7:12am UTC](https://boards.straightdope.com/t/need-help-writting-a-windows-script-file/333523/2 "2005-12-01T07:12:05Z")

</div>

Line 1: SecondsToDelay = “5”  
Line 2: ProgramToRun = “iexplore” 'may need full path  
Line 3: Wscript.Sleep(SecondsToDelay \* 1000)  
Line 4: Prog = Chr(34) & ProgramToRun & Chr(34)  
Line 5: CreateObject(“WScript.Shell”).Run(Prog)

The simple answer:  
On line 2, set ProgramToRun =  
“H:\Program Files\RAMpage\RAMpage.exe” & Chr(34) & " M=100 T=600 A D=Y P=" & Chr(34) & “H:\Program Files\RAMpage\RAMpageConfig.exe”

A more complex answer:  
On line 2, set ProgramToRun =  
Chr(34) & “H:\Program Files\RAMpage\RAMpage.exe” & Chr(34) & " M=100 T=600 A D=Y P=" & Chr(34) & “H:\Program Files\RAMpage\RAMpageConfig.exe” & Chr(34)  
Remove line 4.  
On line 5, change Prog to ProgramToRun

Also, you can substitute:  
“”“H:\Program Files\RAMpage\RAMpage.exe”" M=100 T=600 A D=Y P="“H:\Program Files\RAMpage\RAMpageConfig.exe”""  
Into the complex answer on line 2

So, you’ve got either:

SecondsToDelay = “5”  
ProgramToRun = “H:\Program Files\RAMpage\RAMpage.exe” & Chr(34) & " M=100 T=600 A D=Y P=" & Chr(34) & “H:\Program Files\RAMpage\RAMpageConfig.exe”  
Wscript.Sleep(SecondsToDelay \* 1000)  
Prog = Chr(34) & ProgramToRun & Chr(34)  
CreateObject(“WScript.Shell”).Run(Prog)

OR

SecondsToDelay = “5”  
ProgramToRun = Chr(34) & “H:\Program Files\RAMpage\RAMpage.exe” & Chr(34) & " M=100 T=600 A D=Y P=" & Chr(34) & “H:\Program Files\RAMpage\RAMpageConfig.exe” & Chr(34)  
Wscript.Sleep(SecondsToDelay \* 1000)  
CreateObject(“WScript.Shell”).Run(ProgramToRun)

OR

SecondsToDelay = “5”  
ProgramToRun = “”“H:\Program Files\RAMpage\RAMpage.exe”" M=100 T=600 A D=Y P="“H:\Program Files\RAMpage\RAMpageConfig.exe”""  
Wscript.Sleep(SecondsToDelay \* 1000)  
CreateObject(“WScript.Shell”).Run(ProgramToRun)

Your choice.

---

<div class="post-metadata">

**Author:** ![Nobody](https://avatars.discourse-cdn.com/v4/letter/n/94ad74/32.png) [@Nobody](https://boards.straightdope.com/u/Nobody)\
**Post date:** [December 1, 2005, 9:50am UTC](https://boards.straightdope.com/t/need-help-writting-a-windows-script-file/333523/3 "2005-12-01T09:50:41Z")

</div>

> [@ishamael69](#):
>
> Line 1: SecondsToDelay = “5”  
> Line 2: ProgramToRun = “iexplore” 'may need full path  
> Line 3: Wscript.Sleep(SecondsToDelay \* 1000)  
> Line 4: Prog = Chr(34) & ProgramToRun & Chr(34)  
> Line 5: CreateObject(“WScript.Shell”).Run(Prog)
> 
> The simple answer:  
> On line 2, set ProgramToRun =  
> “H:\Program Files\RAMpage\RAMpage.exe” & Chr(34) & " M=100 T=600 A D=Y P=" & Chr(34) & “H:\Program Files\RAMpage\RAMpageConfig.exe”
> 
> A more complex answer:  
> On line 2, set ProgramToRun =  
> Chr(34) & “H:\Program Files\RAMpage\RAMpage.exe” & Chr(34) & " M=100 T=600 A D=Y P=" & Chr(34) & “H:\Program Files\RAMpage\RAMpageConfig.exe” & Chr(34)  
> Remove line 4.  
> On line 5, change Prog to ProgramToRun
> 
> Also, you can substitute:  
> “”“H:\Program Files\RAMpage\RAMpage.exe”" M=100 T=600 A D=Y P="“H:\Program Files\RAMpage\RAMpageConfig.exe”""  
> Into the complex answer on line 2
> 
> So, you’ve got either:
> 
> SecondsToDelay = “5”  
> ProgramToRun = “H:\Program Files\RAMpage\RAMpage.exe” & Chr(34) & " M=100 T=600 A D=Y P=" & Chr(34) & “H:\Program Files\RAMpage\RAMpageConfig.exe”  
> Wscript.Sleep(SecondsToDelay \* 1000)  
> Prog = Chr(34) & ProgramToRun & Chr(34)  
> CreateObject(“WScript.Shell”).Run(Prog)
> 
> OR
> 
> SecondsToDelay = “5”  
> ProgramToRun = Chr(34) & “H:\Program Files\RAMpage\RAMpage.exe” & Chr(34) & " M=100 T=600 A D=Y P=" & Chr(34) & “H:\Program Files\RAMpage\RAMpageConfig.exe” & Chr(34)  
> Wscript.Sleep(SecondsToDelay \* 1000)  
> CreateObject(“WScript.Shell”).Run(ProgramToRun)
> 
> OR
> 
> SecondsToDelay = “5”  
> ProgramToRun = “”“H:\Program Files\RAMpage\RAMpage.exe”" M=100 T=600 A D=Y P="“H:\Program Files\RAMpage\RAMpageConfig.exe”""  
> Wscript.Sleep(SecondsToDelay \* 1000)  
> CreateObject(“WScript.Shell”).Run(ProgramToRun)
> 
> Your choice.

Dang, so many choices, thanks. For some reason the P=“H:\Program Files\RAMpage\RAMpageConfig.exe” was throwing me off (the extra sets of quotation marks), but I guess it’s no problem at all. Thanks.

---

<div class="post-metadata">

**Author:** ![ishamael69](https://avatars.discourse-cdn.com/v4/letter/i/b9e5f3/32.png) [@ishamael69](https://boards.straightdope.com/u/ishamael69)\
**Post date:** [December 2, 2005, 5:33am UTC](https://boards.straightdope.com/t/need-help-writting-a-windows-script-file/333523/4 "2005-12-02T05:33:05Z")

</div>

You are welcome. For the record, to put a quotation mark in a string, just put two double quotation marks together ("") inside the string. Otherwise, you can put Chr(34) + “String” + Chr(34)

---

<div class="post-metadata">

**Author:** ![Nobody](https://avatars.discourse-cdn.com/v4/letter/n/94ad74/32.png) [@Nobody](https://boards.straightdope.com/u/Nobody)\
**Post date:** [December 2, 2005, 7:35am UTC](https://boards.straightdope.com/t/need-help-writting-a-windows-script-file/333523/5 "2005-12-02T07:35:06Z")

</div>

> [@ishamael69](#):
>
> You are welcome. For the record, to put a quotation mark in a string, just put two double quotation marks together ("") inside the string. Otherwise, you can put Chr(34) + “String” + Chr(34)

Thanks.  
If you wouldn’t mind, one last question, do you have any idea for this problem I’m encountering? I made the script file, and test ran it, but for some reason, even though the path and filename are completely correct  
CreateObject(“WScript.Shell”).Run(“H:\Program Files\Creative\SB Live! 24-bit\Surround Mixer\CTSysVol.exe /r”)  
returns the error “System can’t find the file specified”. 😕

---

<div class="post-metadata">

**Author:** ![Nanoda](https://avatars.discourse-cdn.com/v4/letter/n/ce73a5/32.png) [@Nanoda](https://boards.straightdope.com/u/Nanoda)\
**Post date:** [December 2, 2005, 8:46am UTC](https://boards.straightdope.com/t/need-help-writting-a-windows-script-file/333523/6 "2005-12-02T08:46:15Z")

</div>

I don’t have a solution, but try removing the /r switch - it’s possible it’s interpreted as being part of the filename string, thus causing a failure.

I had a similar problem once, but I’m afraid I don’t recall how I solved it.

---

<div class="post-metadata">

**Author:** ![Otanx](https://avatars.discourse-cdn.com/v4/letter/o/c5a1d2/32.png) [@Otanx](https://boards.straightdope.com/u/Otanx)\
**Post date:** [December 2, 2005, 2:46pm UTC](https://boards.straightdope.com/t/need-help-writting-a-windows-script-file/333523/7 "2005-12-02T14:46:02Z")

</div>

Not sure if this is required in XP/2000 but I know in 95/98 sometimes it would have problems with long directory names. Might want to try the 8 character dir names instead. I haven’t done any programing for a long long time so this might no longer be a problem.

(“H:\Progra~1\Creative\SB Liv~1\Surrou~1\CTSysVol.exe /r”)  
If 2 or more dir start with the same letters then use ~2 ~3 etc. They are sorted alphabetically for the number extention.

-Otanx

---

<div class="post-metadata">

**Author:** ![Nobody](https://avatars.discourse-cdn.com/v4/letter/n/94ad74/32.png) [@Nobody](https://boards.straightdope.com/u/Nobody)\
**Post date:** [December 2, 2005, 4:54pm UTC](https://boards.straightdope.com/t/need-help-writting-a-windows-script-file/333523/8 "2005-12-02T16:54:32Z")

</div>

Thank you Nanoda and Otanx, but those didn’t work. Oh well, I have the weekend to fiddle around and see if I can come up with someting that works.
