Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


What is wrong with this?

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> What is wrong with this?
  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 >>
 What is wrong with this? - 10/24/2007 7:40:10 PM   
  phil999

 

Posts: 38
Score: 0
Joined: 5/4/2007
Status: offline
  So this is so strange

      

For reason the script does not see the space in Program files it is just looking in C:\program

yet if i msgbox "C:\Program" & " Files\test\cachepassword.vbs" the correct path is shown with the space.

This is driving me mad so any help is appreicated.

Cheers

Phil
 
 
Post #: 1
 
 RE: What is wrong with this? - 10/24/2007 7:46:43 PM   
  ehvbs

 

Posts: 2223
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi phil999,

the full file spec has to be quoted, so try

  winsh.run "runas /profile /user:" & strusername & " cmd.exe /k cscript """ & strScript & """"

Good luck! (because I didn't test and may have messed up the """"")

ehvbs

(in reply to phil999)
 
 
Post #: 2
 
 RE: What is wrong with this? - 10/24/2007 7:58:47 PM   
  phil999

 

Posts: 38
Score: 0
Joined: 5/4/2007
Status: offline
I tried it an failed.

(in reply to ehvbs)
 
 
Post #: 3
 
 RE: What is wrong with this? - 10/24/2007 8:13:52 PM   
  ehvbs

 

Posts: 2223
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi phil999,

(1) execute the command from a command line shell, experiment with the quotes, if it works

(2) copy the command line via clipboard into a .bat file, test it, if it works

(3) call the .bat from the script

(4) (optional) try to run the command line (with "" for ") from your script

Good luck!

ehvbs

(in reply to phil999)
 
 
Post #: 4
 
 RE: What is wrong with this? - 10/24/2007 8:14:56 PM   
  phil999

 

Posts: 38
Score: 0
Joined: 5/4/2007
Status: offline
I should add the script works as long as the path of the file is not c:\program files for example if its c:\cachepassword.vbs it will work fine.                

(in reply to phil999)
 
 
Post #: 5
 
 RE: What is wrong with this? - 10/24/2007 8:20:08 PM   
  DiGiTAL.SkReAM


Posts: 1194
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
Try using this line, instead:

strScript = Chr(34) & "C:\Program Files\test\cachepassword.vbs" & Chr(34)

_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to ehvbs)
 
 
Post #: 6
 
 RE: What is wrong with this? - 10/24/2007 8:27:15 PM   
  ehvbs

 

Posts: 2223
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
(1) Using chr(34) instead of """" doesn't change anything

(2) look at the examples given by runas /?, especially

  runas /env /user:Benutzer@Domäne.Microsoft.com "notepad \"Meine Datei.txt\""

(3) make sure it works from the command line and post the working line

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 7
 
 RE: What is wrong with this? - 10/24/2007 9:18:19 PM   
  phil999

 

Posts: 38
Score: 0
Joined: 5/4/2007
Status: offline
OK so from the command line this works

runas /profile /user:domain\user "cmd.exe /k cscript" & "%programfiles%\test\cachepassword.vbs"

but for some reason the below doesnt work in vbs

winsh.run "runas /profile /user:" & strusername & "cmd.exe /k cscript" & "%programfiles%\test\cachepassword.vbs"

(in reply to ehvbs)
 
 
Post #: 8
 
 RE: What is wrong with this? - 10/24/2007 9:39:02 PM   
  ehvbs

 

Posts: 2223
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi phil999,

I have problems to believe, that this

   runas /profile /user:domain\user "cmd.exe /k cscript" & "%programfiles%\test\cachepassword.vbs"

is a copy of your command line.

If you are still in experimental mode, try

  winsh.run "runas /profile /user:" & strusername & " ""cmd.exe /k cscript """"%programfiles%\test\cachepassword.vbs"""""""

  winsh.run "runas /profile /user:" & strusername & " ""cmd.exe /k cscript \""%programfiles%\test\cachepassword.vbs\"""""

I add some missing spaces and may have miscounted the "; you could add something like

strScript = "C:\Program" & " Files\test\cachepassword.vbs"
strCmd = "runas /profile /user:" & strusername & " ""cmd.exe /k cscript """"%programfiles%\test\cachepassword.vbs"""""""
WScript.Echo strCmd
winsh.run strCmd

and post the output.




 

(in reply to phil999)
 
 
Post #: 9
 
 RE: What is wrong with this? - 10/24/2007 9:56:09 PM   
  phil999

 

Posts: 38
Score: 0
Joined: 5/4/2007
Status: offline
i love you.......

winsh.run "runas /profile /user:" & strusername & " ""cmd.exe /k cscript \""%programfiles%\test\cachepassword.vbs\"""""

thats what was needed...

(in reply to ehvbs)
 
 
Post #: 10
 
 
 
  

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 >> What is wrong with this? 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