Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,661 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,178 people online right now. Registration is fast and FREE... Join Now!




vbs file?

 
Reply to this topicStart new topic

vbs file?

StunnaBeats
post 15 Aug, 2008 - 03:04 PM
Post #1


New D.I.C Head

*
Joined: 15 Aug, 2008
Posts: 3

Ok, I don't know much about doing vbs files. I'm trying to make a vbs that moves a file to the computer's startup folder, and then open's up another file (IN THAT ORDER). Help please?
User is offlineProfile CardPM

Go to the top of the page

dineeshd
post 16 Aug, 2008 - 01:40 AM
Post #2


D.I.C Addict

Group Icon
Joined: 30 Jun, 2008
Posts: 560



Thanked 16 times

Dream Kudos: 575
My Contributions


Moving File...

vb
dim fso

Set ws = WScript.CreateObject("WScript.Shell")

fso.MoveFile "c:\file.txt", "C:\Documents and Settings\All Users\Start

Menu\Programs\Startup\"

set fso = Nothing


Opening an exe file...

vb
dim objShell
dim strCommand

set objShell = WScript.CreateObject("Wscript.Shell")
strCommand = CHR(34) & "C:\FILE.exe" & CHR(34)
objShell.run strCommand ,6 ,"FALSE"

set objShell = Nothing


Opening other files....

vb
dim objShell, file_path, PROGRAME_PATH 

Set objShell = WScript.CreateObject("WScript.Shell")

PROGRAME_PATH = "C:\Program Files\Microsoft Office\Office"

file_path = CHR(34) & "C:\file.doc" & CHR(34)

objShell.Run CHR(34) & PROGRAME_PATH & "\winword.exe" & CHR(34) & file_path, 0, "FALSE"


Here you need to specify the path(PROGRAME_PATH) and exe file name bases on the file association.

Hope this helps...... biggrin.gif
User is online!Profile CardPM

Go to the top of the page

StunnaBeats
post 18 Aug, 2008 - 12:35 PM
Post #3


New D.I.C Head

*
Joined: 15 Aug, 2008
Posts: 3

QUOTE(dineeshd @ 16 Aug, 2008 - 02:40 AM) *

Moving File...

vb
dim fso

Set ws = WScript.CreateObject("WScript.Shell")

fso.MoveFile "c:\file.txt", "C:\Documents and Settings\All Users\Start

Menu\Programs\Startup\"

set fso = Nothing


Opening an exe file...

vb
dim objShell
dim strCommand

set objShell = WScript.CreateObject("Wscript.Shell")
strCommand = CHR(34) & "C:\FILE.exe" & CHR(34)
objShell.run strCommand ,6 ,"FALSE"

set objShell = Nothing


Opening other files....

vb
dim objShell, file_path, PROGRAME_PATH 

Set objShell = WScript.CreateObject("WScript.Shell")

PROGRAME_PATH = "C:\Program Files\Microsoft Office\Office"

file_path = CHR(34) & "C:\file.doc" & CHR(34)

objShell.Run CHR(34) & PROGRAME_PATH & "\winword.exe" & CHR(34) & file_path, 0, "FALSE"


Here you need to specify the path(PROGRAME_PATH) and exe file name bases on the file association.

Hope this helps...... biggrin.gif




I tried the code to move files, but it didnt work. It gave me an error. I save it as a vbs right??

Here's wat i put:

CODE

dim fso  
  
Set ws = WScript.CreateObject("WScript.Shell")  
  
fso.MoveFile "C:\Users\richard\Desktop\file.txt", "C:\Documents and Settings\All Users\Start  
  
Menu\Programs\Startup\"  
  
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 18 Aug, 2008 - 01:36 PM
Post #4


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,933



Thanked 118 times

Dream Kudos: 8525

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


Well what error did it give?
User is offlineProfile CardPM

Go to the top of the page

StunnaBeats
post 19 Aug, 2008 - 01:06 PM
Post #5


New D.I.C Head

*
Joined: 15 Aug, 2008
Posts: 3

QUOTE(PsychoCoder @ 18 Aug, 2008 - 02:36 PM) *

Well what error did it give?


it said something like "Expected error" or something, and it said the line number and like character 64
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 19 Aug, 2008 - 01:10 PM
Post #6


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,933



Thanked 118 times

Dream Kudos: 8525

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


@StunnaBeats:

We need to know what error before we can even start helping.
User is offlineProfile CardPM

Go to the top of the page

dineeshd
post 20 Aug, 2008 - 12:23 AM
Post #7


D.I.C Addict

Group Icon
Joined: 30 Jun, 2008
Posts: 560



Thanked 16 times

Dream Kudos: 575
My Contributions


You need to tell the exact error message and the procedure you followed to execute the script.
User is online!Profile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 05:40AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month