/build/static/layout/Breadcrumb_cap_w.png

Vb script to check the environment variable and copy files.

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

Answers (4)

Posted by: mayur_mak 12 years ago
Senior Purple Belt
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
Posted by: anonymous_9363 12 years ago
Red Belt
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! :-)
Posted by: mayur_mak 12 years ago
Senior Purple Belt
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
Posted by: virtualize 12 years ago
Orange Senior Belt
0
Thanks guys it worked for me....
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ