Page 1 of 1 1
Topic Options
#212314 - 2017-03-02 10:27 PM Copy to local drive then remove
Sweeny Offline
Fresh Scripter

Registered: 2016-03-18
Posts: 18
Loc: Hampshire
To the good people of the Kixtart forum,
I have a script which resides on a file share. For unrelated reasons that script needs to be run locally on the machine and can't be run from the file share. Could someone point me in the right direction to how I'd go about automatically copying the script to a temporary location on the local drive, letting it run then removing the script from the local machine
Many thanks in advance,
Tom

Top
#212317 - 2017-03-03 12:04 AM Re: Copy to local drive then remove [Re: Sweeny]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
If you are running it from the logon script it would be nothing more than something like the following.
Copy the file to the %temp% directory.
shell "%temp%\filename.exe"

if you need to run it at a later time, scheduling it with Task Scheduler would be the way to go. Search the board.

Top
#212318 - 2017-03-03 10:44 AM Re: Copy to local drive then remove [Re: Allen]
Sweeny Offline
Fresh Scripter

Registered: 2016-03-18
Posts: 18
Loc: Hampshire
Thank you for the advice Allen, I will see what I can get working. The script isn't run from a logon script, it is a standalone script that a technician has to manually run. The issue I am having is the technician not copying the script from the file server onto the local drive before instigating the script. To get round the issue I hoped I'd be able to code in the ability for the script to copy itself and run from the local version then delete itself.
Or am I making this harder than it should be? (not unusual ;\) )
Many thanks,
Tom

Top
#212319 - 2017-03-03 11:38 AM Re: Copy to local drive then remove [Re: Sweeny]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
What if you put the script in a folder with only read access for the people that need to run the script, copy it from there to a local drive, start it and afterwards delete it?

Something like this?
Completely untested but I am just trying to push you in the right direction.

 Code:
Break on

? "Copying script to local drive and starting it. Standby...."

$source = "\\server\share\script.kix"
$destination = "C:\Folder\"

Copy $source $destination

$Shellline = "Kix32.exe " + $destination + "Script.kix"
Shell $shellline

Del $destination + "Script.kix"
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#212320 - 2017-03-03 03:54 PM Re: Copy to local drive then remove [Re: Mart]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
If you have sensitive information in the script you could also tokenize it. This would at least obscure the code from prying eyes.
Top
#212321 - 2017-03-03 04:05 PM Re: Copy to local drive then remove [Re: Mart]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
Maybe something like this?
 Code:
If Left(@ScriptDir, 3) <> "C:\"		; NOT RUNNING FROM C:\
	If Exist("%temp%\TempScript.kix")
		Del "%temp%\TempScript.kix"
	EndIf
	Copy @ScriptDir+"\"+@ScriptName "%temp%\TempScript.kix"
	Shell '\\server\share\path\to\wkix32.exe "%temp%\TempScript.kix"'
	Del "%temp%\TempScript.kix"
	Exit 0
EndIf


Edited by ShaneEP (2017-03-03 04:11 PM)
Edit Reason: Forgot to delete the script after running

Top
#212322 - 2017-03-03 04:27 PM Re: Copy to local drive then remove [Re: ShaneEP]
Sweeny Offline
Fresh Scripter

Registered: 2016-03-18
Posts: 18
Loc: Hampshire
Thank you everyone for the advice, I will test and hope for the best \:\)
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 515 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.028 seconds in which 0.011 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org