I need a vb script that checks the environment varable fro e.g "user_pro" where user_pro will have value based on the region (for e.g gid and zip). If user_pro is "gid" then copy files to the network path. and this should work when i launch the shortcut.

thanks
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
Hi

Chk the following Script if it suits .as per yr requirement modify it
U need to do error handling based upon the requirement

Set objShell = WScript.CreateObject("WScript.Shell")
Set goFSO = CreateObject("Scripting.FileSystemObject")

strRegKeyValue = objShell.RegRead ("HKLM\SYSTEM\CurrentControlSet\Control\SessionManager\Environment\user_pro")

'1)Chk here whether network is online
'2)Chk whether required folder exsits on the network where files needs to be copied
'3)run the main shortcut even if error during copy or not
'4)Here file_path_main is the location of the shortcut EXE


If strRegKeyValue = "gid" Then
dest_loc = 'your orginal file path which needs to be copied
goFSO.CopyFile str_server_file_loc, dest_loc, True
Wscript.Sleep 500 'time interval depends upon the number of files and size

objShell.run Chr(34) & file_path_main & Chr(34)

End If

regards,
Mayur Makwana
Answered 08/11/2011 by: mayur_mak
Senior Purple Belt

Please log in to comment
0
Almost, but I'm guessing that the OP would want to have more than one region so, rather than a single 'If...End If', he'd require a 'Select Case' construct:Select Case strRegKeyValue
Case "gid"
dest_loc = "somewhere"
Case "zip"
dest_loc = "somewhere_else"
Case Else
dest_loc = "some_default_place"
End Select

goFSO.CopyFile str_server_file_loc, dest_loc, True
<etc, etc>
I have *no* idea why you have included a Sleep method: the 'Run' line won't execute until the file copy operation is complete.

Lastly, note the use of AD's CODE tag! :-)
Answered 08/12/2011 by: VBScab
Red Belt

Please log in to comment
0
@VBscab

I agree with you.
This is just a basic script and not a full fledged script.Its for only understanding purpose.

Since it is not clearly specified whether the shortcut will perform only copy task while launching or after copy it will run the shortcut exe file.As a result a run command is included.

regards
Mayur MAkwana
Answered 08/12/2011 by: mayur_mak
Senior Purple Belt

Please log in to comment
0
Thanks guys it worked for me....
Answered 09/14/2011 by: virtualize
Orange Senior Belt

Please log in to comment
Answer this question or Comment on this question for clarity