1
votes

While running a VBS file (launching a script), it is not doing anything.

Below is the path with parameteres -

Set Wshell = CreateObject("Wscript.Shell")
Platform = "abc"
userID = "bce"
MacroName = "cde"
starttime = "date1"
endtime = "date2"
value1 till value 20 are blank i.e. ""

Macro_Parameters = CHR(34) & Platform & CHR(34) & " " & Chr(34) & UserId & CHR(34) & " " & Chr(34) & MacroName & CHR(34) & " " & Chr(34) & starttime & CHR(34) & " " & Chr(34) & endtime & CHR(34) & " " & Chr(34) & CLAIM_ID & CHR(34) & " " & Chr(34) & VALUE1 & CHR(34) & " " & Chr(34) & VALUE2 & CHR(34) & " " & Chr(34) & VALUE3  & CHR(34) & " " & Chr(34) & VALUE4 & CHR(34) & " " & Chr(34) & VALUE5 & CHR(34) & " " & Chr(34) & VALUE6 & CHR(34) & " " & Chr(34) & VALUE7 & CHR(34) & " " & Chr(34) & VALUE8 & CHR(34) & " " & Chr(34) & VALUE9 & CHR(34) & " " & Chr(34) & VALUE10 & CHR(34) & " " & Chr(34) & VALUE11 & CHR(34) & " " & Chr(34) & VALUE12 & CHR(34) & " " & Chr(34) & VALUE13 & CHR(34) & " " & Chr(34) & VALUE14 & CHR(34) & " " & Chr(34) & VALUE15 & CHR(34) & " " & Chr(34) & VALUE16 & CHR(34) & " " & Chr(34) & VALUE17 & CHR(34) & " " & Chr(34) & VALUE18 & CHR(34) & " " & Chr(34) & VALUE19 & CHR(34) & " " & Chr(34) & VALUE20 & Chr(34)

fileProgram = Chr(34) & "C:\Users\%username%\Logs\Script.vbs" & Chr(34)
filelaunch = fileProgram & " " & Macro_Parameters

On Error Resume Next
returnError = Wshell.Run(filelaunch)  '

It has more then 20 parameters. Not sure if parameters are limiting this script to run.

1
What happen when you execute this script without On Error Reume Next ? - Hackoo
How did you verify that it really isn't "doing anything"? What is the return code? Does the other script do some logging? Can you add logging to it if it doesn't? - Ansgar Wiechers
@Hackoo If I use it without On error resume Next, it errors out. And I am using this script in PCOMM macro so it is not giving the exact error description as well. - AV-In
Well, what is the error? - Ansgar Wiechers
@AnsgarWiechers could you please help me out how I use logging in the script. - AV-In

1 Answers

-1
votes

The problem is %username% resolves to %userName% and not the variable. You can use this to get the user name

Set oShell  = CreateObject("WScript.Shell")

strUserName = oShell.ExpandEnvironmentStrings("%USERNAME%")

and then use it as so

fileProgram = Chr(34) & "C:\Users\" & strUserName& "\Logs\Script.vbs" & Chr(34)