ssathre Posted April 22, 2009 Posted April 22, 2009 Hello, I have a script that uses PSEXEC to launch processes on several of our remote servers. It has been working great for some time now. However, our corporate virus scanner is picking up PSEXEC as a virus and promptly deletes this file every day. The network admins wont add this to the allowed list as it is used by the conflicker worm and several others. To get around this i have a batch file that checks to see of psexec is in the windows/system32 folder and if not it copies it there. I would like to incorporate this into my auto IT code so when I execute the script it will check and copy the file if necessary. could someone please help me with this? Here is my batch file code: @ECHO OFF c: IF EXIST %windir%\system32\pskill.exe GOTO :next copy "\\path\PsTools\pskill.exe" %windir%\system32\pskill.exe :next IF EXIST %windir%\system32\psexec.exe GOTO :end copy "\\path\psexec.exe" %windir%\system32\psexec.exe :end Thanks
Developers Jos Posted April 22, 2009 Developers Posted April 22, 2009 What did you find in the helpfile for file exist? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
ssathre Posted April 22, 2009 Author Posted April 22, 2009 What did you find in the helpfile for file exist?nothing that I understood. thats why I came here looking for help and maybe an example? I guess im a bit daft, Sorry.
Developers Jos Posted April 22, 2009 Developers Posted April 22, 2009 nothing that I understood. thats why I came here looking for help and maybe an example? I guess im a bit daft, Sorry.For me it comes up with the fileexists() function. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
lordicast Posted April 22, 2009 Posted April 22, 2009 From Help If FileExists("C:\autoexec.bat") Then MsgBox(4096, "C:\autoexec.bat File", "Exists") Else MsgBox(4096,"C:\autoexec.bat File", "Does NOT exists") EndIf [Cheeky]Comment[/Cheeky]
ssathre Posted April 23, 2009 Author Posted April 23, 2009 From Help If FileExists("C:\autoexec.bat") Then MsgBox(4096, "C:\autoexec.bat File", "Exists") Else MsgBox(4096,"C:\autoexec.bat File", "Does NOT exists") EndIf Im sorry but "HELP" isnt helping much. While it is showing a generic if file exists function is does not show how to achieve the script that I originally posted. I guess I was hoping for a bit more community help other than RTFM. Thanks
lordicast Posted April 23, 2009 Posted April 23, 2009 (edited) Im sorry but "HELP" isnt helping much. While it is showing a generic if file exists function is does not show how to achieve the script that I originally posted. I guess I was hoping for a bit more community help other than RTFM. Thanks Whats so hard here?? Help If FileExists("C:\autoexec.bat") Then MsgBox(4096, "C:\autoexec.bat File", "Exists") Else MsgBox(4096,"C:\autoexec.bat File", "Does NOT exists") EndIf If FileExists("C:\") Then MsgBox(4096, "C:\ Dir ", "Exists") Else MsgBox(4096,"C:\ Dir" , "Does NOT exists") EndIfoÝ÷ Ù«¢+Ù%¥±á¥ÍÑÌ¡]¥¹½ÝͥȵÀìÌäìÀäÈíÍåÍÑ´ÌÈÀäÈíÁÍ¥±°¹áÌäì¤Q¡¸(ͱÀ ÄÀÀ¤ì%á¥ÍÐͱÀ¼¹½Ñ¡¥¹±Í)±Í(¥± ½Áä¡ÍÉ¥ÁѥȵÀìÌäìÀäÈíÁÑ ÀäÈíAÍQ½½±ÌÀäÈíÁÍ¥±°¹áÌäì±]¥¹½ÝͥȵÀìÌäìÀäÈíÍåÍÑ´ÌÈÀäÈíÁÍ¥±°¹áÌäì°ä¤í ½Á䥱ɽ´å½ÕÈÁÑ Ñ¼Ñ¡Ý¥¹½ÝÌÁÑ )¹%(ìô¹ÉÁÐÝ¥Ñ Í½¹¥±)%¥±á¥ÍÑÌ¡]¥¹½ÝͥȵÀìÌäìÀäÈíÍåÍÑ´ÌÈÀäÈíÁÍá¹áÌäì¤Q¡¸(ͱÀ ÄÀÀ¤)±Í(¥± ½Áä¡ÍÉ¥ÁѥȵÀìÌäìÀäÈíÁÑ ÀäÈíÁÍá¹áÌäì±]¥¹½ÝͥȵÀìÌäìÀäÈíÍåÍÑ´ÌÈÀäÈíÁÍ¥±°¹áÌäì°ä¤)¹% edit* , i have 3rd grade skillz o Yeah because 4th graders can spell Edited April 23, 2009 by lordicast [Cheeky]Comment[/Cheeky]
ssathre Posted April 23, 2009 Author Posted April 23, 2009 Whats so hard here?? Help If FileExists("C:\autoexec.bat") Then MsgBox(4096, "C:\autoexec.bat File", "Exists") Else MsgBox(4096,"C:\autoexec.bat File", "Does NOT exists") EndIf If FileExists("C:\") Then MsgBox(4096, "C:\ Dir ", "Exists") Else MsgBox(4096,"C:\ Dir" , "Does NOT exists") EndIfoÝ÷ Û*.®Ç+ZºÚ"µÍY[Q^ÝÊÚ[ÝÜÑ [È ÌÎNÉÌLÜÞÝ[LÌÌLÜÚÚ[^IÌÎNÊH[ÛY L HÈQ^ÝÛYZØHÈÝ[È[ÙB[ÙBQ[PÛÜJØÜ [È ÌÎNÉÌLÜ] ÌLÔÕÛÛÉÌLÜÚÚ[^IÌÎNËÚ[ÝÜÑ [È ÌÎNÉÌLÜÞÝ[LÌÌLÜÚÚ[^IÌÎNÎJNÐÛÜH[HÛH[Ý]ÈHÚ[ÝÜÈ][YÏH[X]Ú]ÙXÛÛ[BY[Q^ÝÊÚ[ÝÜÑ [È ÌÎNÉÌLÜÞÝ[LÌÌLÜÙ^XË^IÌÎNÊH[ÛY L B[ÙBQ[PÛÜJØÜ [È ÌÎNÉÌLÜ] ÌLÜÙ^XË^IÌÎNËÚ[ÝÜÑ [È ÌÎNÉÌLÜÞÝ[LÌÌLÜÚÚ[^IÌÎNÎJB[Y i have 3rd grade skillz o Yeah Lordicast, thanks for the code however it throws an error in expression on line 4
lordicast Posted April 23, 2009 Posted April 23, 2009 oops didnt test heres a better one @systemdir is the windows\system32 folder If FileExists(@SystemDir & '\pskill.exe') Then sleep(100) ; IF exist sleep aka do nothing else Else FileCopy(@scriptdir & '\path\PsTools\pskil.exe',@SystemDir & '\pskill.exe',9);Copy file from your path to the windows path EndIf ;= and repeat with second file If FileExists(@SystemDir & '\psexec.exe') Then sleep(100) Else FileCopy(@scriptdir & '\path\psexec.exe',@SystemDir & 'psexec.exe',9) EndIf [Cheeky]Comment[/Cheeky]
ssathre Posted April 23, 2009 Author Posted April 23, 2009 oops didnt test heres a better one @systemdir is the windows\system32 folder If FileExists(@SystemDir & '\pskill.exe') Then sleep(100) ; IF exist sleep aka do nothing else Else FileCopy(@scriptdir & '\path\PsTools\pskil.exe',@SystemDir & '\pskill.exe',9);Copy file from your path to the windows path EndIf ;= and repeat with second file If FileExists(@SystemDir & '\psexec.exe') Then sleep(100) Else FileCopy(@scriptdir & '\path\psexec.exe',@SystemDir & 'psexec.exe',9) EndIf Thanks Lordicast. You gave me what I need to get going. I appreciate your helping an old and tired network admin.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now